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); } } }