Added EntityRegainHealthEvent. Thanks TimWolla!

This commit is contained in:
EvilSeph
2011-06-17 16:47:52 -04:00
parent d471de6bb1
commit 99d9e5f66b
4 changed files with 84 additions and 0 deletions

View File

@@ -39,4 +39,6 @@ public class EntityListener implements Listener {
public void onCreeperPower(CreeperPowerEvent event) {}
public void onEntityTame(EntityTameEvent event) {}
public void onEntityRegainHealth(EntityRegainHealthEvent event) {}
}

View File

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