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:
@@ -360,7 +360,12 @@ public class CraftEventFactory {
|
|||||||
} else {
|
} else {
|
||||||
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, damage);
|
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, damage);
|
||||||
}
|
}
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
|
callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user