mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 06:53:44 +01:00
Added EntityRegainHealthEvent. Thanks TimWolla!
This commit is contained in:
parent
fadd962b9c
commit
f3d25e647f
@ -13,6 +13,7 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public abstract class EntityLiving extends Entity {
|
public abstract class EntityLiving extends Entity {
|
||||||
@ -328,8 +329,17 @@ public abstract class EntityLiving extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void b(int i) {
|
public void b(int i) {
|
||||||
|
// CraftBukkit start - Added event
|
||||||
if (this.health > 0) {
|
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) {
|
if (this.health > 20) {
|
||||||
this.health = 20;
|
this.health = 20;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user