Search in sources :

Example 1 with ManaAbilityProvider

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());
    }
}
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)

Example 2 with ManaAbilityProvider

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);
}
Also used : Absorption(com.archyx.aureliumskills.mana.Absorption) ManaAbilityProvider(com.archyx.aureliumskills.mana.ManaAbilityProvider) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Aggregations

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