Few Fixes (#578)

* Few Fixes

• Fixed BendingDisplay bar not updating for unbound moves
• Fixed NCP NPE - Thanks RoboMWM for pointing this out!

* Fixed null check
This commit is contained in:
StrangeOne101 2016-09-24 06:32:04 +12:00 committed by OmniCypher
parent 7ed5bcd01b
commit 749669e84c
2 changed files with 12 additions and 11 deletions

View file

@ -1415,12 +1415,10 @@ public class PKListener implements Listener {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
int slot = event.getNewSlot() + 1; 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)); 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); WaterArms waterArms = CoreAbility.getAbility(player, WaterArms.class);
if (waterArms != null) { if (waterArms != null) {

View file

@ -28,10 +28,13 @@ public class DamageHandler {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void damageEntity(Entity entity, Player source, double damage, Ability ability, boolean ignoreArmor) { public static void damageEntity(Entity entity, Player source, double damage, Ability ability, boolean ignoreArmor) {
if (ability == null) if (ability == null) {
return; return;
}
if (source == null) {
source = ability.getPlayer();
}
Player player = ability.getPlayer();
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage, ignoreArmor); AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage, ignoreArmor);
Bukkit.getServer().getPluginManager().callEvent(damageEvent); Bukkit.getServer().getPluginManager().callEvent(damageEvent);
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
@ -40,8 +43,8 @@ public class DamageHandler {
} }
if (!damageEvent.isCancelled()) { if (!damageEvent.isCancelled()) {
damage = damageEvent.getDamage(); damage = damageEvent.getDamage();
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) {
NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH); NCPExemptionManager.exemptPermanently(source, CheckType.FIGHT_REACH);
} }
if(((LivingEntity) entity).getHealth() - damage <= 0 && !entity.isDead()) { if(((LivingEntity) entity).getHealth() - damage <= 0 && !entity.isDead()) {
@ -54,15 +57,15 @@ public class DamageHandler {
cause = DamageCause.MAGIC; cause = DamageCause.MAGIC;
} }
EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(player, entity, cause, damage); EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, cause, damage);
if (!finalEvent.isCancelled()) { if (!finalEvent.isCancelled()) {
damage = finalEvent.getDamage(); damage = finalEvent.getDamage();
((LivingEntity) entity).damage(damage, source); ((LivingEntity) entity).damage(damage, source);
entity.setLastDamageCause(finalEvent); entity.setLastDamageCause(finalEvent);
} }
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) { if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) {
NCPExemptionManager.unexempt(player); NCPExemptionManager.unexempt(source);
} }
} }
} }