Added EntityRegainHealthEvent. Thanks TimWolla!
This commit is contained in:
parent
82475d3497
commit
a5e6cfa714
@ -601,6 +601,13 @@ public abstract class Event implements Serializable {
|
|||||||
*/
|
*/
|
||||||
ENTITY_TAME (Category.LIVING_ENTITY),
|
ENTITY_TAME (Category.LIVING_ENTITY),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a LivingEntity is regains health
|
||||||
|
*
|
||||||
|
* @see org.bukkit.event.entity.EntityRegainHealthEvent
|
||||||
|
*/
|
||||||
|
ENTITY_REGAIN_HEALTH (Category.LIVING_ENTITY),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WEATHER EVENTS
|
* WEATHER EVENTS
|
||||||
*/
|
*/
|
||||||
|
@ -39,4 +39,6 @@ public class EntityListener implements Listener {
|
|||||||
public void onCreeperPower(CreeperPowerEvent event) {}
|
public void onCreeperPower(CreeperPowerEvent event) {}
|
||||||
|
|
||||||
public void onEntityTame(EntityTameEvent event) {}
|
public void onEntityTame(EntityTameEvent event) {}
|
||||||
|
|
||||||
|
public void onEntityRegainHealth(EntityRegainHealthEvent event) {}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data for health-regain events
|
||||||
|
*/
|
||||||
|
public class EntityRegainHealthEvent extends EntityEvent implements Cancellable {
|
||||||
|
|
||||||
|
private boolean cancelled;
|
||||||
|
private int amount;
|
||||||
|
|
||||||
|
public EntityRegainHealthEvent(Entity entity, int amount)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of regained health
|
||||||
|
* @return The amount of health regained
|
||||||
|
*/
|
||||||
|
public int getAmount()
|
||||||
|
{
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of regained health
|
||||||
|
*/
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cancellation state of this event. A cancelled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* If a health-regain event is cancelled, the entity won't get health.
|
||||||
|
* This will not fire an event.
|
||||||
|
*
|
||||||
|
* @return true if this event is cancelled
|
||||||
|
*/
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event. A cancelled event will not
|
||||||
|
* be executed in the server, but will still pass to other plugins
|
||||||
|
*
|
||||||
|
* If a health-regain event is cancelled, the entity won't get health.
|
||||||
|
* This will not fire an event.
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
@ -690,6 +690,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case ENTITY_REGAIN_HEALTH:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((EntityListener) listener).onEntityRegainHealth((EntityRegainHealthEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Vehicle Events
|
// Vehicle Events
|
||||||
case VEHICLE_CREATE:
|
case VEHICLE_CREATE:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user