From 047224a4cb42705843e453c656158220ad17a1ed Mon Sep 17 00:00:00 2001 From: Sobki Date: Thu, 26 Jan 2017 12:47:20 +1000 Subject: [PATCH] Fixed passives being enabled/disabled at wrong times (#711) --- src/com/projectkorra/projectkorra/BendingPlayer.java | 4 ---- src/com/projectkorra/projectkorra/PKListener.java | 10 +++++----- .../projectkorra/chiblocking/Paralyze.java | 4 ---- .../projectkorra/firebending/passive/FirePassive.java | 2 +- .../projectkorra/waterbending/blood/Bloodbending.java | 4 ---- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/com/projectkorra/projectkorra/BendingPlayer.java b/src/com/projectkorra/projectkorra/BendingPlayer.java index 0f76292a..0ea17a0c 100644 --- a/src/com/projectkorra/projectkorra/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/BendingPlayer.java @@ -21,7 +21,6 @@ import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.WaterAbility; -import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.chiblocking.Paralyze; import com.projectkorra.projectkorra.command.Commands; @@ -249,8 +248,6 @@ public class BendingPlayer { return false; } else if (!hasElement(element)) { return false; - } else if (isChiBlocked() || isParalyzed() || isBloodbent()) { - return false; } else if (disabledWorlds != null && disabledWorlds.contains(player.getWorld().getName())) { return false; } @@ -745,7 +742,6 @@ public class BendingPlayer { */ public void toggleBending() { toggled = !toggled; - PassiveManager.registerPassives(player); } public void toggleElement(Element element) { diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index 45b917ff..c2f37e9a 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -765,7 +765,7 @@ public class PKListener implements Listener { new Shockwave(player, true); } - if (!event.isCancelled() && bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.AIR)) { + if (!event.isCancelled() && bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.AIR) && bPlayer.canUsePassive(Element.AIR)) { new AirBurst(player, true); if (CoreAbility.getAbility(GracefulDescent.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(GracefulDescent.class))) { event.setDamage(0D); @@ -773,21 +773,21 @@ public class PKListener implements Listener { } } - if (!event.isCancelled() && bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.WATER) && CoreAbility.getAbility(Hydrosink.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Hydrosink.class))) { + if (!event.isCancelled() && bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.WATER) && bPlayer.canUsePassive(Element.WATER) && CoreAbility.getAbility(Hydrosink.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Hydrosink.class))) { if (WaterPassive.applyNoFall(player)) { event.setDamage(0D); event.setCancelled(true); } } - if (!event.isCancelled() && bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.EARTH) && CoreAbility.getAbility(DensityShift.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(DensityShift.class))) { + if (!event.isCancelled() && bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.EARTH) && bPlayer.canUsePassive(Element.EARTH) && CoreAbility.getAbility(DensityShift.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(DensityShift.class))) { if (EarthPassive.softenLanding(player)) { event.setDamage(0D); event.setCancelled(true); } } - if (!event.isCancelled() && bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.CHI) && CoreAbility.getAbility(Acrobatics.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Acrobatics.class))) { + if (!event.isCancelled() && bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(Element.CHI) && bPlayer.canUsePassive(Element.CHI) && CoreAbility.getAbility(Acrobatics.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Acrobatics.class))) { double initdamage = event.getDamage(); double newdamage = event.getDamage() * ChiPassive.getFallReductionFactor(); double finaldamage = initdamage - newdamage; @@ -803,7 +803,7 @@ public class PKListener implements Listener { } } - if (bPlayer.canBendPassive(Element.FIRE) && bPlayer.hasElement(Element.FIRE) && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) { + if (bPlayer.canBendPassive(Element.FIRE) && bPlayer.hasElement(Element.FIRE) && bPlayer.canUsePassive(Element.FIRE) && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) { event.setCancelled(!HeatControl.canBurn(player)); } diff --git a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java index 50b46bca..0bbabdd7 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java +++ b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.ability.ChiAbility; -import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.command.Commands; @@ -73,9 +72,6 @@ public class Paralyze extends ChiAbility { return true; } ENTITIES.remove(entity); - if (entity instanceof Player) { - PassiveManager.registerPassives((Player) entity); - } } return false; diff --git a/src/com/projectkorra/projectkorra/firebending/passive/FirePassive.java b/src/com/projectkorra/projectkorra/firebending/passive/FirePassive.java index a2cf2e6c..3675d402 100644 --- a/src/com/projectkorra/projectkorra/firebending/passive/FirePassive.java +++ b/src/com/projectkorra/projectkorra/firebending/passive/FirePassive.java @@ -18,7 +18,7 @@ public class FirePassive { } for (Player player : Bukkit.getOnlinePlayers()) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer != null && bPlayer.canBendPassive(Element.FIRE)) { + if (bPlayer != null && bPlayer.canBendPassive(Element.FIRE) && bPlayer.canUsePassive(Element.FIRE)) { if (player.getFireTicks() > 80) { player.setFireTicks(80); } diff --git a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java index 9318ff42..fdb83e09 100644 --- a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java @@ -19,7 +19,6 @@ import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.BloodAbility; -import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.util.DamageHandler; @@ -286,9 +285,6 @@ public class Bloodbending extends BloodAbility { for (Entity e : TARGETED_ENTITIES.keySet()) { if (TARGETED_ENTITIES.get(e) == player) { TARGETED_ENTITIES.remove(e); - if (e instanceof Player) { - PassiveManager.registerPassives((Player) e); - } } }