Search in sources :

Example 1 with ChargedShot

use of com.archyx.aureliumskills.mana.ChargedShot 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());
    }
}
Also used : ChargedShot(com.archyx.aureliumskills.mana.ChargedShot) ManaAbilityProvider(com.archyx.aureliumskills.mana.ManaAbilityProvider) PlayerData(com.archyx.aureliumskills.data.PlayerData) DamageType(com.archyx.aureliumskills.util.mechanics.DamageType) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PlayerData (com.archyx.aureliumskills.data.PlayerData)1 ChargedShot (com.archyx.aureliumskills.mana.ChargedShot)1 ManaAbilityProvider (com.archyx.aureliumskills.mana.ManaAbilityProvider)1 DamageType (com.archyx.aureliumskills.util.mechanics.DamageType)1 EventHandler (org.bukkit.event.EventHandler)1