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,12 +58,8 @@ public class DamageHandler {
} }
EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, cause, damage); EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(source, entity, cause, damage);
Bukkit.getServer().getPluginManager().callEvent(finalEvent); ((LivingEntity) entity).damage(damage, source);
if (!finalEvent.isCancelled()) { entity.setLastDamageCause(finalEvent);
damage = finalEvent.getDamage();
((LivingEntity) entity).damage(damage, source);
entity.setLastDamageCause(finalEvent);
}
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) { if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus") && source != null) {
NCPExemptionManager.unexempt(source); NCPExemptionManager.unexempt(source);