Search in sources :

Example 41 with PlayerData

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

the class HealingAbilities method lifeSteal.

@EventHandler
public void lifeSteal(EntityDeathEvent event) {
    if (blockDisabled(Ability.LIFE_STEAL))
        return;
    LivingEntity entity = event.getEntity();
    boolean hostile = entity instanceof Monster || entity instanceof Player;
    if (XMaterial.isNewVersion()) {
        if (entity instanceof Phantom) {
            hostile = true;
        }
    }
    if (hostile) {
        if (entity.getKiller() == null)
            return;
        Player player = entity.getKiller();
        if (player.equals(entity))
            return;
        if (blockAbility(player))
            return;
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        if (playerData.getAbilityLevel(Ability.LIFE_STEAL) > 0) {
            AttributeInstance entityAttribute = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH);
            if (entityAttribute == null)
                return;
            double maxHealth = entityAttribute.getValue();
            double percent = getValue(Ability.LIFE_STEAL, playerData) / 100;
            double healthRegen = maxHealth * percent;
            AttributeInstance playerAttribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
            if (playerAttribute == null)
                return;
            player.setHealth(player.getHealth() + Math.min(healthRegen, playerAttribute.getValue() - player.getHealth()));
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) Monster(org.bukkit.entity.Monster) AttributeInstance(org.bukkit.attribute.AttributeInstance) Phantom(org.bukkit.entity.Phantom) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 42 with PlayerData

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

the class AlchemyAbilities method getSplasherMultiplier.

private double getSplasherMultiplier(ProjectileSource source, Collection<LivingEntity> affectedEntities) {
    double splasherMultiplier = 1.0;
    if (source instanceof Player) {
        Player player = (Player) source;
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData != null && plugin.getAbilityManager().isEnabled(Ability.SPLASHER)) {
            if (playerData.getAbilityLevel(Ability.SPLASHER) > 0) {
                double splasherPercent = getValue(Ability.SPLASHER, playerData);
                int affectedPlayers = (int) affectedEntities.stream().filter(entity -> entity instanceof Player).filter(entity -> plugin.getPlayerManager().getPlayerData(entity.getUniqueId()) != null).count();
                splasherMultiplier = 1 + (splasherPercent / 100 * affectedPlayers);
            }
        }
    }
    return splasherMultiplier;
}
Also used : AbilityProvider(com.archyx.aureliumskills.ability.AbilityProvider) java.util(java.util) BrewerInventory(org.bukkit.inventory.BrewerInventory) ItemMeta(org.bukkit.inventory.meta.ItemMeta) PlayerItemConsumeEvent(org.bukkit.event.player.PlayerItemConsumeEvent) OptionL(com.archyx.aureliumskills.configuration.OptionL) AbilityMessage(com.archyx.aureliumskills.lang.AbilityMessage) Player(org.bukkit.entity.Player) LingeringPotion(org.bukkit.entity.LingeringPotion) AreaEffectCloud(org.bukkit.entity.AreaEffectCloud) EventHandler(org.bukkit.event.EventHandler) TextUtil(com.archyx.aureliumskills.util.text.TextUtil) Option(com.archyx.aureliumskills.configuration.Option) AureliumSkills(com.archyx.aureliumskills.AureliumSkills) Lang(com.archyx.aureliumskills.lang.Lang) PotionMeta(org.bukkit.inventory.meta.PotionMeta) Skills(com.archyx.aureliumskills.skills.Skills) ProjectileSource(org.bukkit.projectiles.ProjectileSource) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) PotionSplashEvent(org.bukkit.event.entity.PotionSplashEvent) PotionUtil(com.archyx.aureliumskills.util.mechanics.PotionUtil) PotionType(org.bukkit.potion.PotionType) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) AgilityAbilities(com.archyx.aureliumskills.skills.agility.AgilityAbilities) LivingEntity(org.bukkit.entity.LivingEntity) NBTItem(de.tr7zw.changeme.nbtapi.NBTItem) PotionData(org.bukkit.potion.PotionData) OfflinePlayer(org.bukkit.OfflinePlayer) ItemStack(org.bukkit.inventory.ItemStack) PotionEffect(org.bukkit.potion.PotionEffect) InvocationTargetException(java.lang.reflect.InvocationTargetException) NBTCompound(de.tr7zw.changeme.nbtapi.NBTCompound) NBTAPIUser(com.archyx.aureliumskills.util.item.NBTAPIUser) LingeringPotionSplashEvent(org.bukkit.event.entity.LingeringPotionSplashEvent) BrewEvent(org.bukkit.event.inventory.BrewEvent) NumberUtil(com.archyx.aureliumskills.util.math.NumberUtil) EventPriority(org.bukkit.event.EventPriority) StatModifier(com.archyx.aureliumskills.modifier.StatModifier) PlayerData(com.archyx.aureliumskills.data.PlayerData) VersionUtils(com.archyx.aureliumskills.util.version.VersionUtils) Ability(com.archyx.aureliumskills.ability.Ability) Stats(com.archyx.aureliumskills.stats.Stats) PotionEffectType(org.bukkit.potion.PotionEffectType) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 43 with PlayerData

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

the class FarmingAbilities method tripleHarvest.

public void tripleHarvest(Player player, Block block) {
    if (OptionL.isEnabled(Skills.FARMING)) {
        if (plugin.getAbilityManager().isEnabled(Ability.TRIPLE_HARVEST)) {
            if (player.getGameMode().equals(GameMode.SURVIVAL)) {
                PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
                if (playerData == null)
                    return;
                if (playerData.getAbilityLevel(Ability.TRIPLE_HARVEST) > 0) {
                    if (r.nextDouble() < (getValue(Ability.TRIPLE_HARVEST, playerData)) / 100) {
                        for (ItemStack item : block.getDrops()) {
                            checkMelonSilkTouch(player, block, item);
                            ItemStack droppedItem = item.clone();
                            droppedItem.setAmount(2);
                            PlayerLootDropEvent event = new PlayerLootDropEvent(player, droppedItem, block.getLocation().add(0.5, 0.5, 0.5), LootDropCause.TRIPLE_HARVEST);
                            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 44 with PlayerData

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

the class FarmingAbilities method geneticist.

@EventHandler
public void geneticist(PlayerItemConsumeEvent event) {
    if (blockDisabled(Ability.GENETICIST))
        return;
    Player player = event.getPlayer();
    if (blockAbility(player))
        return;
    Material mat = event.getItem().getType();
    if (mat.equals(Material.BREAD) || mat.equals(Material.APPLE) || mat.equals(Material.GOLDEN_APPLE) || mat.equals(XMaterial.POTATO.parseMaterial()) || mat.equals(Material.BAKED_POTATO) || mat.equals(XMaterial.CARROT.parseMaterial()) || mat.equals(Material.GOLDEN_CARROT) || mat.equals(Material.MELON) || mat.equals(Material.PUMPKIN_PIE) || mat.equals(Material.BEETROOT) || mat.equals(Material.BEETROOT_SOUP) || mat.equals(XMaterial.MUSHROOM_STEW.parseMaterial()) || mat.equals(Material.POISONOUS_POTATO)) {
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        float amount = (float) getValue(Ability.GENETICIST, playerData) / 10;
        player.setSaturation(player.getSaturation() + amount);
    }
}
Also used : Player(org.bukkit.entity.Player) XMaterial(com.cryptomorin.xseries.XMaterial) Material(org.bukkit.Material) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 45 with PlayerData

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

the class FishingAbilities method grappler.

@EventHandler
public void grappler(PlayerFishEvent event) {
    if (blockDisabled(Ability.GRAPPLER))
        return;
    if (event.getCaught() != null) {
        if (!(event.getCaught() instanceof Item)) {
            PlayerData playerData = plugin.getPlayerManager().getPlayerData(event.getPlayer());
            if (playerData != null) {
                Player player = event.getPlayer();
                if (blockAbility(player))
                    return;
                Vector vector = player.getLocation().toVector().subtract(event.getCaught().getLocation().toVector());
                Vector result = vector.multiply(0.004 + (getValue(Ability.GRAPPLER, playerData) / 25000));
                if (isUnsafeVelocity(result)) {
                    // Prevent excessive velocity warnings
                    return;
                }
                event.getCaught().setVelocity(result);
            }
        }
    }
}
Also used : Item(org.bukkit.entity.Item) Player(org.bukkit.entity.Player) PlayerData(com.archyx.aureliumskills.data.PlayerData) Vector(org.bukkit.util.Vector) 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