From 749669e84c66dab5d0db1fcd278d56cf9b871274 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Sat, 24 Sep 2016 06:32:04 +1200 Subject: [PATCH] Few Fixes (#578) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Few Fixes • Fixed BendingDisplay bar not updating for unbound moves • Fixed NCP NPE - Thanks RoboMWM for pointing this out! * Fixed null check --- .../projectkorra/projectkorra/PKListener.java | 6 ++---- .../projectkorra/util/DamageHandler.java | 17 ++++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index afb434b7..905a84f6 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -1415,11 +1415,9 @@ public class PKListener implements Listener { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); int slot = event.getNewSlot() + 1; - if (bPlayer.getAbilities().get(slot) != null ) { + if (bPlayer != null && bPlayer.getAbilities() != null) { CoreAbility ability = CoreAbility.getAbility(bPlayer.getAbilities().get(slot)); - if (ability != null) { - GeneralMethods.displayMovePreview(player, ability); - } + GeneralMethods.displayMovePreview(player, ability); } WaterArms waterArms = CoreAbility.getAbility(player, WaterArms.class); diff --git a/src/com/projectkorra/projectkorra/util/DamageHandler.java b/src/com/projectkorra/projectkorra/util/DamageHandler.java index 57703a8f..baeb0b88 100644 --- a/src/com/projectkorra/projectkorra/util/DamageHandler.java +++ b/src/com/projectkorra/projectkorra/util/DamageHandler.java @@ -28,10 +28,13 @@ public class DamageHandler { @SuppressWarnings("deprecation") public static void damageEntity(Entity entity, Player source, double damage, Ability ability, boolean ignoreArmor) { - if (ability == null) + if (ability == null) { return; + } + if (source == null) { + source = ability.getPlayer(); + } - Player player = ability.getPlayer(); AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage, ignoreArmor); Bukkit.getServer().getPluginManager().callEvent(damageEvent); if (entity instanceof LivingEntity) { @@ -40,8 +43,8 @@ public class DamageHandler { } if (!damageEvent.isCancelled()) { damage = damageEvent.getDamage(); - if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { - NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH); + if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) { + NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_REACH); } if(((LivingEntity) entity).getHealth() - damage <= 0 && !entity.isDead()) { @@ -54,15 +57,15 @@ public class DamageHandler { cause = DamageCause.MAGIC; } - EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(player, entity, cause, damage); + EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, cause, damage); if (!finalEvent.isCancelled()) { damage = finalEvent.getDamage(); ((LivingEntity) entity).damage(damage, source); entity.setLastDamageCause(finalEvent); } - if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { - NCPExemptionManager.unexempt(player); + if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) { + NCPExemptionManager.unexempt(source); } } }