use of com.archyx.aureliumskills.mana.ManaAbilityProvider in project AureliumSkills by Archy-X.
the class DamageListener method onDamage.
@EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageByEntityEvent event) {
// Check if not cancelled
if (event.isCancelled()) {
return;
}
// Gets the player who dealt damage
Player player = getDamager(event.getDamager());
if (player != null) {
// Check disabled world
if (plugin.getWorldManager().isInDisabledWorld(player.getLocation())) {
return;
}
// Gets player skill
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
DamageType damageType = getDamageType(event, player);
// Applies strength
strength.strength(event, playerData, damageType);
// Applies master abilities
switch(damageType) {
case SWORD:
fightingAbilities.swordMaster(event, player, playerData);
break;
case BOW:
archeryAbilities.bowMaster(event, player, playerData);
break;
case AXE:
foragingAbilities.axeMaster(event, player, playerData);
break;
case PICKAXE:
miningAbilities.pickMaster(event, player, playerData);
break;
case HOE:
farmingAbilities.scytheMaster(event, player, playerData);
break;
case SHOVEL:
excavationAbilities.spadeMaster(event, player, playerData);
break;
}
// First strike
if (damageType == DamageType.SWORD) {
fightingAbilities.firstStrike(event, playerData, player);
}
// Critical
if (OptionL.criticalEnabled(damageType)) {
critical.applyCrit(event, player, playerData);
}
// Charged shot
if (damageType == DamageType.BOW) {
ManaAbilityProvider provider = plugin.getManaAbilityManager().getProvider(MAbility.CHARGED_SHOT);
if (provider instanceof ChargedShot) {
ChargedShot chargedShot = (ChargedShot) provider;
chargedShot.applyChargedShot(event);
}
}
}
// Handles being damaged
if (event.getEntity() instanceof Player) {
onDamaged(event, (Player) event.getEntity());
}
}
use of com.archyx.aureliumskills.mana.ManaAbilityProvider in project AureliumSkills by Archy-X.
the class DamageListener method onDamaged.
private void onDamaged(EntityDamageByEntityEvent event, Player player) {
// Check disabled world
if (plugin.getWorldManager().isInDisabledWorld(player.getLocation())) {
return;
}
// Gets player skill
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
// Checks for absorption activation and applies
ManaAbilityProvider provider = plugin.getManaAbilityManager().getProvider(MAbility.ABSORPTION);
if (provider instanceof Absorption) {
Absorption absorption = (Absorption) provider;
absorption.handleAbsorption(event, player, playerData);
}
if (event.isCancelled())
return;
// Handles toughness
Toughness.onDamage(event, playerData);
// Handles mob master
defenseAbilities.mobMaster(event, playerData);
// Handles shielding
defenseAbilities.shielding(event, playerData, player);
}
Aggregations