diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-05 19:18:05 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-05 19:23:54 +1100 |
commit | bf60f44013adaa05e93d5ce865f686349a0ee97f (patch) | |
tree | 0c1a39cbad40409beee7168df27c84bd04296581 | |
parent | b1a3aa602a8021228e3cdf429cb613c590ceb122 (diff) | |
download | craftbukkit-bf60f44013adaa05e93d5ce865f686349a0ee97f.tar craftbukkit-bf60f44013adaa05e93d5ce865f686349a0ee97f.tar.gz craftbukkit-bf60f44013adaa05e93d5ce865f686349a0ee97f.tar.lz craftbukkit-bf60f44013adaa05e93d5ce865f686349a0ee97f.tar.xz craftbukkit-bf60f44013adaa05e93d5ce865f686349a0ee97f.zip |
Teach EnderDragon how to throw EntityDamage events
Relates to BUKKIT-129
-rw-r--r-- | src/main/java/net/minecraft/server/EntityEnderDragon.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java index e0836fe5..2897ab4f 100644 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -1,5 +1,9 @@ package net.minecraft.server; +import org.bukkit.Bukkit; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; + import java.util.Iterator; import java.util.List; @@ -388,7 +392,19 @@ public class EntityEnderDragon extends EntityComplex { Entity entity = (Entity) list.get(i); if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.mobAttack(this), 10); + // CraftBukkit start - throw damage events when the dragon attacks + // The EntityHuman case is handled in EntityHuman, so don't throw it here + if (!(entity instanceof EntityHuman)) { + EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 10); + Bukkit.getPluginManager().callEvent(damageEvent); + + if (!damageEvent.isCancelled()) { + entity.damageEntity(DamageSource.mobAttack(this), damageEvent.getDamage()); + } + } else { + entity.damageEntity(DamageSource.mobAttack(this), 10); + } + // CraftBukkit end } } } |