diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java index f886727b5a..c8b7a4e57e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java @@ -11,15 +11,12 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable private boolean cancelled; private int amount; + private RegainReason regainReason; - public EntityRegainHealthEvent(Entity entity, int amount) { + public EntityRegainHealthEvent(Entity entity, int amount, RegainReason regainReason) { super(Event.Type.ENTITY_REGAIN_HEALTH, entity); this.amount = amount; - } - - protected EntityRegainHealthEvent(Event.Type type, Entity entity, int amount) { - super(type, entity); - this.amount = amount; + this.regainReason = regainReason; } /** @@ -64,4 +61,32 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable public void setCancelled(boolean cancel) { cancelled = cancel; } + + /** + * Gets the reason for why the entity is regaining health + * + * @return A RegainReason detailing the reason for the entity regaining health + */ + public RegainReason getRegainReason() { + return regainReason; + } + + /** + * An enum to specify the type of health regaining + */ + public enum RegainReason { + + /** + * When a player regains health from regenerating due to Peaceful mode (spawn-monsters=false) + */ + REGEN, + /** + * When a player regains health from eating consumables + */ + EATING, + /** + * Any other reason not covered by the reasons above + */ + CUSTOM + } }