diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java index b6426146f..94c55cc50 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java @@ -1,6 +1,8 @@ package mineplex.minecraft.game.classcombat.Skill.Knight; import java.util.HashSet; +import java.util.Iterator; +import java.util.Map.Entry; import java.util.WeakHashMap; import org.bukkit.entity.Player; @@ -21,7 +23,7 @@ import mineplex.minecraft.game.classcombat.Skill.SkillFactory; public class Fortitude extends Skill { private WeakHashMap _preHealth = new WeakHashMap(); - private WeakHashMap _health = new WeakHashMap(); + private WeakHashMap _health = new WeakHashMap(); private WeakHashMap _last = new WeakHashMap(); public Fortitude(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) @@ -34,7 +36,7 @@ public class Fortitude extends Skill "up to #0#1 of the health you lost.", "", "You restore health at a rate of", - "1 health per #3.5#-0.5 seconds.", + "1 health per #3#-0.5 seconds.", "", "This does not stack, and is reset if", "you are hit again." @@ -74,7 +76,7 @@ public class Fortitude extends Skill double diff = _preHealth.remove(damagee) - damagee.getHealth(); - _health.put(damagee, Math.min(level,(int)(diff + 0.5))); + _health.put(damagee, Math.min(level, diff)); _last.put(damagee, System.currentTimeMillis()); } @@ -84,33 +86,35 @@ public class Fortitude extends Skill if (event.getType() != UpdateType.FASTER) return; - HashSet remove = new HashSet(); - - for (Player cur : _health.keySet()) + Iterator> healthIterator = _health.entrySet().iterator(); + + while (healthIterator.hasNext()) { - int level = getLevel(cur); - if (level == 0) continue; - - if (UtilTime.elapsed(_last.get(cur), 3500 - (500 * level))) - { - _health.put(cur, _health.get(cur) - 1); - _last.put(cur, System.currentTimeMillis()); - - if (_health.get(cur) <= 0) - remove.add(cur); - - //Heal - UtilPlayer.health(cur, 1); - - //Effect - UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation(), 0, 0.2f, 0, 0, 1); - } - } - - for (Player cur : remove) - { - _health.remove(cur); - _last.remove(cur); + Entry entry = healthIterator.next(); + + int level = getLevel(entry.getKey()); + if (level == 0) + continue; + + if (!UtilTime.elapsed(_last.get(entry.getKey()), 3000 - (500 * level))) + continue; + + //Work out healing + double toHeal = Math.min(entry.getValue(), 1); + entry.setValue(entry.getValue() - toHeal); + + //Heal + UtilPlayer.health(entry.getKey(), toHeal); + + //Effect + UtilParticle.PlayParticle(ParticleType.HEART, entry.getKey().getEyeLocation(), 0, 0.2f, 0, 0, 1); + + //Finished + if (entry.getValue() <= 0) + healthIterator.remove(); + + //Last Tick + _last.put(entry.getKey(), System.currentTimeMillis()); } }