geforkt von Mirrors/Paper
Added reasons for entities regaining health.
By: EvilSeph <evilseph@unaligned.org>
Dieser Commit ist enthalten in:
Ursprung
eae5329f9c
Commit
1325d8f15d
@ -11,15 +11,12 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
|
|||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private int amount;
|
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);
|
super(Event.Type.ENTITY_REGAIN_HEALTH, entity);
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
this.regainReason = regainReason;
|
||||||
|
|
||||||
protected EntityRegainHealthEvent(Event.Type type, Entity entity, int amount) {
|
|
||||||
super(type, entity);
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,4 +61,32 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
|
|||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
cancelled = 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren