From f3d25e647f8ffc256fc26cdd0fa2b2843702555a Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Fri, 17 Jun 2011 16:50:56 -0400 Subject: [PATCH] Added EntityRegainHealthEvent. Thanks TimWolla! --- src/main/java/net/minecraft/server/EntityLiving.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 81b35e07c6..1b9e54fc67 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -13,6 +13,7 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; // CraftBukkit end public abstract class EntityLiving extends Entity { @@ -328,8 +329,17 @@ public abstract class EntityLiving extends Entity { } public void b(int i) { + // CraftBukkit start - Added event if (this.health > 0) { - this.health += i; + CraftServer server = this.world.getServer(); + org.bukkit.entity.Entity entity = this.getBukkitEntity(); + EntityRegainHealthEvent event = new EntityRegainHealthEvent(entity, i); + server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.health += event.getAmount(); + } + // CraftBukkit end if (this.health > 20) { this.health = 20; }