Search in sources :

Example 46 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class ForagingAbilities method lumberjack.

public void lumberjack(Player player, Block block) {
    if (OptionL.isEnabled(Skills.FORAGING)) {
        if (plugin.getAbilityManager().isEnabled(Ability.LUMBERJACK)) {
            if (player.getGameMode().equals(GameMode.SURVIVAL)) {
                PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
                if (playerData == null)
                    return;
                if (playerData.getAbilityLevel(Ability.LUMBERJACK) > 0) {
                    if (r.nextDouble() < ((getValue(Ability.LUMBERJACK, playerData)) / 100)) {
                        for (ItemStack item : block.getDrops(player.getInventory().getItemInMainHand())) {
                            PlayerLootDropEvent event = new PlayerLootDropEvent(player, item.clone(), block.getLocation().add(0.5, 0.5, 0.5), LootDropCause.LUMBERJACK);
                            Bukkit.getPluginManager().callEvent(event);
                            if (!event.isCancelled()) {
                                block.getWorld().dropItem(event.getLocation(), event.getItemStack());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : PlayerLootDropEvent(com.archyx.aureliumskills.api.event.PlayerLootDropEvent) ItemStack(org.bukkit.inventory.ItemStack) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 47 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class ArcheryAbilities method archeryListener.

@EventHandler(priority = EventPriority.HIGH)
public void archeryListener(EntityDamageByEntityEvent event) {
    if (OptionL.isEnabled(Skills.ARCHERY)) {
        if (!event.isCancelled()) {
            if (event.getDamager() instanceof Arrow) {
                Arrow arrow = (Arrow) event.getDamager();
                if (arrow.getShooter() instanceof Player) {
                    Player player = (Player) arrow.getShooter();
                    if (blockAbility(player))
                        return;
                    // Applies abilities
                    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
                    if (playerData == null)
                        return;
                    AbilityManager options = plugin.getAbilityManager();
                    if (options.isEnabled(Ability.STUN)) {
                        if (event.getEntity() instanceof LivingEntity) {
                            LivingEntity entity = (LivingEntity) event.getEntity();
                            stun(playerData, entity);
                        }
                    }
                    if (options.isEnabled(Ability.PIERCING)) {
                        piercing(event, playerData, player, arrow);
                    }
                }
            }
        }
    }
}
Also used : Arrow(org.bukkit.entity.Arrow) LivingEntity(org.bukkit.entity.LivingEntity) AbilityManager(com.archyx.aureliumskills.ability.AbilityManager) Player(org.bukkit.entity.Player) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 48 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class DefenseAbilities method defenseListener.

@EventHandler
public void defenseListener(EntityDamageByEntityEvent event) {
    if (OptionL.isEnabled(Skills.DEFENSE)) {
        if (!event.isCancelled()) {
            if (event.getEntity() instanceof Player) {
                Player player = (Player) event.getEntity();
                if (blockAbility(player))
                    return;
                PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
                if (playerData == null)
                    return;
                if (plugin.getAbilityManager().isEnabled(Ability.NO_DEBUFF)) {
                    if (event.getDamager() instanceof LivingEntity) {
                        LivingEntity entity = (LivingEntity) event.getDamager();
                        noDebuffFire(playerData, player, entity);
                    }
                }
                if (plugin.getAbilityManager().isEnabled(Ability.IMMUNITY)) {
                    immunity(event, playerData);
                }
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 49 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class DefenseAbilities method noDebuff.

@EventHandler
public void noDebuff(PotionSplashEvent event) {
    if (blockDisabled(Ability.NO_DEBUFF))
        return;
    for (LivingEntity entity : event.getAffectedEntities()) {
        if (entity instanceof Player) {
            Player player = (Player) entity;
            if (blockAbility(player))
                return;
            for (PotionEffect effect : event.getPotion().getEffects()) {
                PotionEffectType type = effect.getType();
                if (type.equals(PotionEffectType.POISON) || type.equals(PotionEffectType.UNLUCK) || type.equals(PotionEffectType.WITHER) || type.equals(PotionEffectType.WEAKNESS) || type.equals(PotionEffectType.SLOW_DIGGING) || type.equals(PotionEffectType.SLOW) || type.equals(PotionEffectType.HUNGER) || type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.CONFUSION) || type.equals(PotionEffectType.BLINDNESS)) {
                    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
                    if (playerData == null)
                        return;
                    double chance = getValue(Ability.NO_DEBUFF, playerData) / 100;
                    if (r.nextDouble() < chance) {
                        if (!player.hasPotionEffect(type)) {
                            event.setIntensity(entity, 0);
                        }
                    }
                }
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) PotionEffect(org.bukkit.potion.PotionEffect) PotionEffectType(org.bukkit.potion.PotionEffectType) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 50 with PlayerData

use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.

the class EnchantingAbilities method xpWarrior.

@EventHandler
public void xpWarrior(EntityDeathEvent event) {
    if (blockDisabled(Ability.XP_WARRIOR))
        return;
    LivingEntity entity = event.getEntity();
    if (entity.getKiller() != null) {
        Player player = entity.getKiller();
        if (blockAbility(player))
            return;
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData != null) {
            if (playerData.getAbilityLevel(Ability.XP_WARRIOR) > 0 && event.getDroppedExp() > 0) {
                if (random.nextDouble() < getValue(Ability.XP_WARRIOR, playerData) / 100) {
                    event.setDroppedExp(event.getDroppedExp() * 2);
                }
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PlayerData (com.archyx.aureliumskills.data.PlayerData)111 Player (org.bukkit.entity.Player)54 EventHandler (org.bukkit.event.EventHandler)43 Locale (java.util.Locale)27 ItemStack (org.bukkit.inventory.ItemStack)25 Skill (com.archyx.aureliumskills.skills.Skill)15 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 Stat (com.archyx.aureliumskills.stats.Stat)9 AttributeInstance (org.bukkit.attribute.AttributeInstance)8 PlayerLootDropEvent (com.archyx.aureliumskills.api.event.PlayerLootDropEvent)7 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)7 Material (org.bukkit.Material)7 LivingEntity (org.bukkit.entity.LivingEntity)7 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)6 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)5 OptionL (com.archyx.aureliumskills.configuration.OptionL)5 AbilityData (com.archyx.aureliumskills.data.AbilityData)5 File (java.io.File)5 IOException (java.io.IOException)5 PlayerDataLoadEvent (com.archyx.aureliumskills.data.PlayerDataLoadEvent)4