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.
This commit is contained in:
feildmaster committed 2012-07-02 22:22:03 -05:00
1 parent e4e994f710
commit 00efc8c464
7 files changed
+20 -1

No files matched your search

@@ -144,6 +144,7 @@ public class Explosion {
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
entity.damageEntity(DamageSource.EXPLOSION, event.getDamage());
entity.motX += d0 * d10;
entity.motY += d1 * d10;