Apply setLastDamageCause after processing events and the event has not been canceled. Fixes BUKKIT-1881

This allows previous causes to be available during the event, as well as making the damage cause a valid one. If EntityDamageEvent is canceled, then it's not the last DamageCause.

Also prevents setting DamageCause involuntarily through construction.

By: feildmaster <admin@feildmaster.com>
This commit is contained in:
CraftBukkit/Spigot 2012-07-01 05:04:06 -05:00
parent fdbd4efbd6
commit 87d5b5e374

View File

@ -360,7 +360,12 @@ public class CraftEventFactory {
} else {
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, damage);
}
Bukkit.getPluginManager().callEvent(event);
callEvent(event);
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
}
return event;
}