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

View file

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