use a damage event only for setting last damage cause (#649)

Firing this tricks other plugins into believing this entity was damaged.

In addition, Entity#damage also fires a damage event, so no need to fire a duplicate one.
This commit is contained in:
RoboMWM 2016-11-29 14:08:19 -08:00 committed by Christopher Martin
parent cbb3581a12
commit 3613ca6577

View file

@ -58,13 +58,9 @@ public class DamageHandler {
}
EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, cause, damage);
Bukkit.getServer().getPluginManager().callEvent(finalEvent);
if (!finalEvent.isCancelled()) {
damage = finalEvent.getDamage();
((LivingEntity) entity).damage(damage, source);
entity.setLastDamageCause(finalEvent);
}
((LivingEntity) entity).damage(damage, source);
entity.setLastDamageCause(finalEvent);
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) {
NCPExemptionManager.unexempt(source);
}