diff --git a/pom.xml b/pom.xml index 5d743dc4..90900150 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ strife - 3.3.0 + 3.3.1 jar strife diff --git a/src/main/java/land/face/strife/commands/StrifeCommand.java b/src/main/java/land/face/strife/commands/StrifeCommand.java index d4e3cd17..2105fa6a 100644 --- a/src/main/java/land/face/strife/commands/StrifeCommand.java +++ b/src/main/java/land/face/strife/commands/StrifeCommand.java @@ -41,6 +41,7 @@ import land.face.strife.data.champion.ChampionSaveData; import land.face.strife.data.champion.LifeSkillType; import land.face.strife.data.champion.StrifeAttribute; +import land.face.strife.menus.abilities.ReturnButton; import land.face.strife.stats.AbilitySlot; import land.face.strife.util.EloUtil; import land.face.strife.util.TargetingUtil; @@ -116,6 +117,12 @@ public void cooldownCommand(CommandSender sender, OnlinePlayer target) { target.getPlayer().resetCooldown(); } + @Subcommand("swing") + @CommandCompletion("@players") + public void swinfCommand(CommandSender sender, OnlinePlayer target) { + target.getPlayer().swingMainHand(); + } + @Subcommand("reload") @CommandPermission("strife.admin") public void reloadCommand(CommandSender sender) { @@ -270,6 +277,7 @@ public void removeAbilityCommand(CommandSender sender, OnlinePlayer target, int @CommandCompletion("@players") @CommandPermission("strife.admin") public void menuAbilityCommand(CommandSender sender, OnlinePlayer target) { + ReturnButton.setBackButtonEnabled(target.getPlayer(), true); plugin.getAbilityPicker().open(target.getPlayer()); } @@ -277,6 +285,7 @@ public void menuAbilityCommand(CommandSender sender, OnlinePlayer target) { @CommandCompletion("@players") @CommandPermission("strife.admin") public void submenuAbilityCommand(CommandSender sender, OnlinePlayer target, String menu) { + ReturnButton.setBackButtonEnabled(target.getPlayer(), false); plugin.getSubmenu(menu).open(target.getPlayer()); } @@ -359,7 +368,7 @@ public void addSkillXp(CommandSender sender, OnlinePlayer target, String skill, } @Subcommand("addxp") - @CommandCompletion("@players @range:1-1000000") + @CommandCompletion("@players @range:1-10") @CommandPermission("strife.admin") public void addXpCommand(CommandSender sender, OnlinePlayer player, double amount) { plugin.getExperienceManager().addExperience(player.getPlayer(), amount, true); diff --git a/src/main/java/land/face/strife/data/DamageModifiers.java b/src/main/java/land/face/strife/data/DamageModifiers.java index ad899f53..a3d65ebe 100644 --- a/src/main/java/land/face/strife/data/DamageModifiers.java +++ b/src/main/java/land/face/strife/data/DamageModifiers.java @@ -31,6 +31,7 @@ public class DamageModifiers { private boolean consumeEarthRunes = false; private boolean scaleChancesWithAttack = false; private boolean showPopoffs = true; + private boolean bypassBarrier = false; public AttackType getAttackType() { return attackType; @@ -136,6 +137,14 @@ public void setShowPopoffs(boolean showPopoffs) { this.showPopoffs = showPopoffs; } + public boolean isBypassBarrier() { + return bypassBarrier; + } + + public void setBypassBarrier(boolean bypassBarrier) { + this.bypassBarrier = bypassBarrier; + } + public boolean isConsumeEarthRunes() { return consumeEarthRunes; } diff --git a/src/main/java/land/face/strife/data/StrifeMob.java b/src/main/java/land/face/strife/data/StrifeMob.java index 59654822..783377b3 100644 --- a/src/main/java/land/face/strife/data/StrifeMob.java +++ b/src/main/java/land/face/strife/data/StrifeMob.java @@ -96,11 +96,12 @@ public float damageBarrier(float amount) { BarrierTask.spawnBarrierParticles(getEntity(), amount); return 0; } else { + if (barrier > 0) { + BarrierTask.spawnBarrierParticles(getEntity(), barrier); + } barrier = 0; barrierTask.updateArmorBar(this, 0); - float damageAmount = -1 * diff; - BarrierTask.spawnBarrierParticles(getEntity(), damageAmount); - return damageAmount; + return -1 * diff; } } diff --git a/src/main/java/land/face/strife/data/effects/ChaserEffect.java b/src/main/java/land/face/strife/data/effects/ChaserEffect.java index 882407e9..20dedad9 100644 --- a/src/main/java/land/face/strife/data/effects/ChaserEffect.java +++ b/src/main/java/land/face/strife/data/effects/ChaserEffect.java @@ -1,6 +1,5 @@ package land.face.strife.data.effects; -import land.face.strife.StrifePlugin; import land.face.strife.data.LoadedChaser; import land.face.strife.data.StrifeMob; import land.face.strife.util.DamageUtil.OriginLocation; @@ -14,6 +13,7 @@ public class ChaserEffect extends Effect { private OriginLocation originLocation; private Location overrideLocation; private boolean canLocationOverride; + private boolean chaseCaster; @Override public void apply(StrifeMob caster, StrifeMob target) { @@ -25,13 +25,21 @@ public void apply(StrifeMob caster, StrifeMob target) { ); Location location; if (overrideLocation == null) { - location = TargetingUtil.getOriginLocation(caster.getEntity(), originLocation); + if (canLocationOverride) { + location = TargetingUtil.getOriginLocation(target.getEntity(), originLocation); + } else { + location = TargetingUtil.getOriginLocation(caster.getEntity(), originLocation); + } } else { location = overrideLocation; overrideLocation = null; } - StrifePlugin.getInstance().getChaserManager().createChaser(caster, getId(), vector, location, target.getEntity()); + if (chaseCaster) { + getPlugin().getChaserManager().createChaser(caster, getId(), vector, location, caster.getEntity()); + } else { + getPlugin().getChaserManager().createChaser(caster, getId(), vector, location, target.getEntity()); + } } public boolean isCanLocationOverride() { @@ -42,6 +50,9 @@ public void setCanLocationOverride(boolean canLocationOverride) { this.canLocationOverride = canLocationOverride; } + public void setChaseCaster(boolean chaseCaster) { + this.chaseCaster = chaseCaster; + } public void setOverrideLocation(Location location) { overrideLocation = location; diff --git a/src/main/java/land/face/strife/data/effects/Damage.java b/src/main/java/land/face/strife/data/effects/Damage.java index 9c7e58fd..f7849d76 100644 --- a/src/main/java/land/face/strife/data/effects/Damage.java +++ b/src/main/java/land/face/strife/data/effects/Damage.java @@ -2,12 +2,15 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import land.face.strife.StrifePlugin; import land.face.strife.data.BonusDamage; import land.face.strife.data.DamageModifiers; import land.face.strife.data.StrifeMob; +import land.face.strife.data.TargetResponse; import land.face.strife.events.StrifeDamageEvent; import land.face.strife.stats.StrifeStat; import land.face.strife.util.DamageUtil; @@ -15,6 +18,7 @@ import land.face.strife.util.DamageUtil.AttackType; import land.face.strife.util.DamageUtil.DamageType; import org.bukkit.Bukkit; +import org.bukkit.entity.LivingEntity; public class Damage extends Effect { @@ -31,6 +35,9 @@ public class Damage extends Effect { private boolean isBlocking; private boolean applyOnHitEffects; private boolean showPopoffs; + private boolean bypassBarrier; + private List hitEffects = new ArrayList<>(); + private List killEffects = new ArrayList<>(); @Override public void apply(StrifeMob caster, StrifeMob target) { @@ -44,6 +51,7 @@ public void apply(StrifeMob caster, StrifeMob target) { mods.setCanBeBlocked(canBeBlocked); mods.setApplyOnHitEffects(applyOnHitEffects); mods.setShowPopoffs(showPopoffs); + mods.setBypassBarrier(bypassBarrier); if (canSneakAttack && StrifePlugin.getInstance().getStealthManager().isStealthed(caster.getEntity())) { mods.setSneakAttack(true); } @@ -78,7 +86,16 @@ public void apply(StrifeMob caster, StrifeMob target) { } StrifePlugin.getInstance().getDamageManager().dealDamage(caster, target, - (float) strifeDamageEvent.getFinalDamage()); + (float) strifeDamageEvent.getFinalDamage(), mods); + + Set entities = new HashSet<>(); + entities.add(target.getEntity()); + TargetResponse response = new TargetResponse(entities); + + getPlugin().getEffectManager().executeEffectList(caster, response, hitEffects); + if (target.getEntity().isDead()) { + getPlugin().getEffectManager().executeEffectList(caster, response, killEffects); + } if (damage.containsKey(DamageType.PHYSICAL)) { DamageUtil.attemptBleed(caster, target, damage.get(DamageType.PHYSICAL), mods, false); @@ -168,6 +185,22 @@ public void setShowPopoffs(boolean showPopoffs) { this.showPopoffs = showPopoffs; } + public boolean isBypassBarrier() { + return bypassBarrier; + } + + public void setBypassBarrier(boolean bypassBarrier) { + this.bypassBarrier = bypassBarrier; + } + + public List getHitEffects() { + return hitEffects; + } + + public List getKillEffects() { + return killEffects; + } + public boolean isBlocking() { return isBlocking; } diff --git a/src/main/java/land/face/strife/events/PropertyUpdateEvent.java b/src/main/java/land/face/strife/events/PropertyUpdateEvent.java new file mode 100644 index 00000000..dc40b8b8 --- /dev/null +++ b/src/main/java/land/face/strife/events/PropertyUpdateEvent.java @@ -0,0 +1,67 @@ +/** + * The MIT License + * Copyright (c) 2015 Teal Cube Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package land.face.strife.events; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PropertyUpdateEvent extends Event { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + + private final String id; + private final float baseValue; + private float appliedValue; + + public PropertyUpdateEvent(String id, float baseValue) { + this.id = id; + this.baseValue = baseValue; + appliedValue = baseValue; + } + + public String getId() { + return id; + } + + public float getBaseValue() { + return baseValue; + } + + public float getAppliedValue() { + return appliedValue; + } + + public void setAppliedValue(float appliedValue) { + this.appliedValue = appliedValue; + } + + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + +} \ No newline at end of file diff --git a/src/main/java/land/face/strife/listeners/CombatListener.java b/src/main/java/land/face/strife/listeners/CombatListener.java index 70fd3bf6..d2b62029 100644 --- a/src/main/java/land/face/strife/listeners/CombatListener.java +++ b/src/main/java/land/face/strife/listeners/CombatListener.java @@ -272,9 +272,7 @@ public void strifeDamageHandler(EntityDamageByEntityEvent event) { return; } - Bukkit.getLogger().info("e1: " + strifeDamageEvent.getFinalDamage()); float eventDamage = Math.max(0.002f, defender.damageBarrier((float) strifeDamageEvent.getFinalDamage())); - Bukkit.getLogger().info("e2: " + eventDamage); eventDamage = plugin.getDamageManager().doEnergyAbsorb(defender, eventDamage); if (damage.containsKey(DamageType.PHYSICAL)) { @@ -285,7 +283,8 @@ public void strifeDamageHandler(EntityDamageByEntityEvent event) { () -> DamageUtil.postDamage(attacker, defender, damageModifiers), 0L); if (attackEntity instanceof Bee) { - plugin.getDamageManager().dealDamage(attacker, defender, (float) strifeDamageEvent.getFinalDamage()); + plugin.getDamageManager().dealDamage(attacker, defender, + (float) strifeDamageEvent.getFinalDamage(), damageModifiers); event.setCancelled(true); return; } diff --git a/src/main/java/land/face/strife/listeners/ShootListener.java b/src/main/java/land/face/strife/listeners/ShootListener.java index 8afdebdf..1deb95b1 100644 --- a/src/main/java/land/face/strife/listeners/ShootListener.java +++ b/src/main/java/land/face/strife/listeners/ShootListener.java @@ -95,7 +95,6 @@ public void onPlayerArrowShoot(ProjectileLaunchEvent event) { float attackMultiplier = plugin.getAttackSpeedManager().getAttackMultiplier(mob); attackMultiplier = (float) Math.pow(attackMultiplier, 1.5f); - player.resetCooldown(); if (attackMultiplier < 0.1) { event.setCancelled(true); diff --git a/src/main/java/land/face/strife/managers/DamageManager.java b/src/main/java/land/face/strife/managers/DamageManager.java index 9be2b255..8b283cee 100644 --- a/src/main/java/land/face/strife/managers/DamageManager.java +++ b/src/main/java/land/face/strife/managers/DamageManager.java @@ -22,6 +22,7 @@ import java.util.Map; import java.util.UUID; import land.face.strife.StrifePlugin; +import land.face.strife.data.DamageModifiers; import land.face.strife.data.StrifeMob; import land.face.strife.stats.StrifeTrait; import land.face.strife.util.StatUtil; @@ -45,8 +46,10 @@ public double getHandledDamage(Entity entity) { return handledDamages.getOrDefault(entity.getUniqueId(), 0D); } - public double dealDamage(StrifeMob attacker, StrifeMob defender, float damage) { - damage = Math.max(0.002f, defender.damageBarrier(damage)); + public double dealDamage(StrifeMob attacker, StrifeMob defender, float damage, DamageModifiers modifiers) { + if (!modifiers.isBypassBarrier()) { + damage = Math.max(0.002f, defender.damageBarrier(damage)); + } damage = doEnergyAbsorb(defender, damage); if (attacker == defender) { if (damage > defender.getEntity().getHealth()) { diff --git a/src/main/java/land/face/strife/managers/EffectManager.java b/src/main/java/land/face/strife/managers/EffectManager.java index 487f9f23..fb726bee 100644 --- a/src/main/java/land/face/strife/managers/EffectManager.java +++ b/src/main/java/land/face/strife/managers/EffectManager.java @@ -285,6 +285,11 @@ public void loadEffect(String key, ConfigurationSection cs) { ((Damage) effect).setCanSneakAttack(cs.getBoolean("can-sneak-attack", false)); ((Damage) effect).setApplyOnHitEffects(cs.getBoolean("apply-on-hit-effects", attackMult >= 0.7)); ((Damage) effect).setShowPopoffs(cs.getBoolean("show-popoffs", true)); + ((Damage) effect).setBypassBarrier(cs.getBoolean("bypass-barrier", false)); + List hitEffects = cs.getStringList("hit-effects"); + delayedSetEffects(((Damage) effect).getHitEffects(), hitEffects, key, false); + List killEffects = cs.getStringList("kill-effects"); + delayedSetEffects(((Damage) effect).getKillEffects(), killEffects, key, false); ((Damage) effect).setAttackType(AttackType.valueOf(cs.getString("attack-type", "OTHER"))); ConfigurationSection multCs = cs.getConfigurationSection("damage-multipliers"); Map multMap = new HashMap<>(); @@ -334,6 +339,7 @@ public void loadEffect(String key, ConfigurationSection cs) { OriginLocation.valueOf(cs.getString("origin", "HEAD"))); ((ChaserEffect) effect).setLoadedChaser(data); ((ChaserEffect) effect).setCanLocationOverride(cs.getBoolean("location-override", false)); + ((ChaserEffect) effect).setChaseCaster(cs.getBoolean("chase-caster", false)); break; case CONSOLE_COMMAND: effect = new ConsoleCommand(); diff --git a/src/main/java/land/face/strife/menus/abilities/ReturnButton.java b/src/main/java/land/face/strife/menus/abilities/ReturnButton.java index ecfdc04c..bbc86c87 100644 --- a/src/main/java/land/face/strife/menus/abilities/ReturnButton.java +++ b/src/main/java/land/face/strife/menus/abilities/ReturnButton.java @@ -1,27 +1,28 @@ /** * The MIT License Copyright (c) 2015 Teal Cube Games - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - * associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *

+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + *

+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. + *

+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package land.face.strife.menus.abilities; import io.pixeloutlaw.minecraft.spigot.garbage.StringExtensionsKt; import io.pixeloutlaw.minecraft.spigot.hilt.ItemStackExtensionsKt; import java.util.ArrayList; +import java.util.Map; +import java.util.WeakHashMap; import land.face.strife.StrifePlugin; +import land.face.strife.menus.BlankIcon; import ninja.amp.ampmenus.events.ItemClickEvent; import ninja.amp.ampmenus.items.MenuItem; import org.bukkit.Bukkit; @@ -33,6 +34,7 @@ public class ReturnButton extends MenuItem { private final StrifePlugin plugin; + private static final Map noUseMap = new WeakHashMap<>(); public ReturnButton(StrifePlugin plugin, Material material, String name) { super(StringExtensionsKt.chatColorize(name), setNameAndLore(new ItemStack(material), @@ -42,6 +44,9 @@ public ReturnButton(StrifePlugin plugin, Material material, String name) { @Override public ItemStack getFinalIcon(Player player) { + if (noUseMap.containsKey(player)) { + return BlankIcon.getBlankStack(); + } ItemStack stack = getIcon().clone(); ItemStackExtensionsKt.addItemFlags(stack, ItemFlag.HIDE_ATTRIBUTES); ItemStackExtensionsKt.setDisplayName(stack, getDisplayName()); @@ -51,6 +56,11 @@ public ItemStack getFinalIcon(Player player) { @Override public void onItemClick(ItemClickEvent event) { super.onItemClick(event); + if (noUseMap.containsKey(event.getPlayer())) { + event.setWillUpdate(false); + event.setWillClose(false); + return; + } event.setWillClose(true); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> { if (event.getPlayer() != null && event.getPlayer().isValid()) { @@ -59,4 +69,12 @@ public void onItemClick(ItemClickEvent event) { }, 2L); } + public static void setBackButtonEnabled(Player player, boolean value) { + if (value) { + noUseMap.remove(player); + } else { + noUseMap.put(player, true); + } + } + } diff --git a/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java b/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java index d8ea87f1..1d20d9bb 100644 --- a/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java +++ b/src/main/java/land/face/strife/menus/stats/StatsChangeHealthDisplay.java @@ -20,10 +20,9 @@ import com.tealcube.minecraft.bukkit.TextUtils; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; +import java.util.WeakHashMap; import land.face.strife.StrifePlugin; import land.face.strife.data.champion.Champion; import land.face.strife.data.champion.ChampionSaveData; @@ -40,7 +39,7 @@ public class StatsChangeHealthDisplay extends MenuItem { private final StrifePlugin plugin; - private Map selfInspectMap = new HashMap<>(); + private final Map selfInspectMap = new WeakHashMap<>(); StatsChangeHealthDisplay(StrifePlugin plugin) { super(TextUtils.color("&c&lHealth Display Options"), new ItemStack(Material.APPLE)); @@ -51,10 +50,10 @@ public class StatsChangeHealthDisplay extends MenuItem { public ItemStack getFinalIcon(Player commandSender) { Player player = StrifePlugin.getInstance().getStatsMenu().getTargetPlayer(); if (!player.isValid() || commandSender != player) { - selfInspectMap.put(commandSender.getUniqueId(), false); + selfInspectMap.put(commandSender, false); return BlankIcon.getBlankStack(); } - selfInspectMap.put(commandSender.getUniqueId(), true); + selfInspectMap.put(commandSender, true); ItemStack itemStack = new ItemStack(Material.APPLE); ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(itemStack.getType()); itemMeta.setDisplayName(getDisplayName()); @@ -75,7 +74,7 @@ public ItemStack getFinalIcon(Player commandSender) { @Override public void onItemClick(ItemClickEvent event) { super.onItemClick(event); - if (!selfInspectMap.getOrDefault(event.getPlayer().getUniqueId(), false)) { + if (!selfInspectMap.getOrDefault(event.getPlayer(), false)) { return; } Champion champion = plugin.getChampionManager().getChampion(event.getPlayer()); diff --git a/src/main/java/land/face/strife/tasks/EnergyTask.java b/src/main/java/land/face/strife/tasks/EnergyTask.java index 25029a9a..4c7d3e8a 100644 --- a/src/main/java/land/face/strife/tasks/EnergyTask.java +++ b/src/main/java/land/face/strife/tasks/EnergyTask.java @@ -37,7 +37,7 @@ public void run() { return; } - if (mob.getEnergy() >= StatUtil.getMaximumEnergy(mob)) { + if (mob.getStat(StrifeStat.ENERGY) == 0 || mob.getEnergy() >= StatUtil.getMaximumEnergy(mob)) { return; } diff --git a/src/main/java/land/face/strife/util/StatUtil.java b/src/main/java/land/face/strife/util/StatUtil.java index cd5ec88f..080c1e4c 100644 --- a/src/main/java/land/face/strife/util/StatUtil.java +++ b/src/main/java/land/face/strife/util/StatUtil.java @@ -10,8 +10,10 @@ import java.util.Map; import land.face.strife.StrifePlugin; import land.face.strife.data.StrifeMob; +import land.face.strife.events.PropertyUpdateEvent; import land.face.strife.stats.StrifeStat; import land.face.strife.stats.StrifeTrait; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.LivingEntity; @@ -32,11 +34,17 @@ public static float getBarrierRegen(StrifeMob ae) { } public static float getHealth(StrifeMob ae) { - return ae.getStat(StrifeStat.HEALTH) * (1 + ae.getStat(StrifeStat.HEALTH_MULT) / 100); + float amount = ae.getStat(StrifeStat.HEALTH) * (1 + ae.getStat(StrifeStat.HEALTH_MULT) / 100); + PropertyUpdateEvent event = new PropertyUpdateEvent("life", amount); + Bukkit.getPluginManager().callEvent(event); + return event.getAppliedValue(); } public static float getMaximumEnergy(StrifeMob ae) { - return ae.getStat(StrifeStat.ENERGY) * (1 + ae.getStat(StrifeStat.ENERGY_MULT) / 100); + float amount = ae.getStat(StrifeStat.ENERGY) * (1 + ae.getStat(StrifeStat.ENERGY_MULT) / 100); + PropertyUpdateEvent event = new PropertyUpdateEvent("energy", amount); + Bukkit.getPluginManager().callEvent(event); + return event.getAppliedValue(); } public static void changeEnergy(StrifeMob mob, float amount) {