13
0
geforkt von Mirrors/Paper

Added reasons for entities regaining health.

By: EvilSeph <evilseph@unaligned.org>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-06-28 20:10:50 -04:00
Ursprung eae5329f9c
Commit 1325d8f15d

Datei anzeigen

@ -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
}
}