13
0
geforkt von Mirrors/Paper

Added FoodLevelChange event.

By: EvilSeph <evilseph@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-09-21 18:52:23 -04:00
Ursprung 55312ce475
Commit 547ab9f1be
4 geänderte Dateien mit 68 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -703,6 +703,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.EndermanPlaceEvent * @see org.bukkit.event.entity.EndermanPlaceEvent
*/ */
ENDERMAN_PLACE (Category.LIVING_ENTITY), ENDERMAN_PLACE (Category.LIVING_ENTITY),
/**
* Called when a human entity's food level changes
*
* @see org.bukkit.event.entity.FoodLevelChangeEvent
*/
FOOD_LEVEL_CHANGE (Category.LIVING_ENTITY),
/** /**
* WEATHER EVENTS * WEATHER EVENTS

Datei anzeigen

@ -148,4 +148,11 @@ public class EntityListener implements Listener {
* @param event Relevant event details * @param event Relevant event details
*/ */
public void onEndermanPlace(EndermanPlaceEvent event) {} public void onEndermanPlace(EndermanPlaceEvent event) {}
/**
* Called when a human entity's food level changes
*
* @param event Relevant event details
*/
public void onFoodLevelChange(FoodLevelChangeEvent event) {}
} }

Datei anzeigen

@ -0,0 +1,48 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
/**
* Called when a human entity's food level changes
*/
public class FoodLevelChangeEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private int level;
public FoodLevelChangeEvent(Entity what, int level) {
super(Type.FOOD_LEVEL_CHANGE, what);
this.level = level;
}
/**
* Gets the resultant food level that the entity involved in this event should be set to.
* <br /><br />
* Where 20 is a full food bar and 0 is an empty one.
*
* @return The resultant food level
*/
public int getFoodLevel() {
return level;
}
/**
* Sets the resultant food level that the entity involved in this event should be set to
*
* @param level the resultant food level that the entity involved in this event should be set to
*/
public void setFoodLevel(int level) {
if (level > 20) level = 20;
else if (level < 0) level = 0;
this.level = level;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

Datei anzeigen

@ -783,6 +783,13 @@ public class JavaPluginLoader implements PluginLoader {
} }
}; };
case FOOD_LEVEL_CHANGE:
return new EventExecutor() {
public void execute(Listener listener, Event event) {
((EntityListener) listener).onFoodLevelChange((FoodLevelChangeEvent) event);
}
};
// Vehicle Events // Vehicle Events
case VEHICLE_CREATE: case VEHICLE_CREATE:
return new EventExecutor() { return new EventExecutor() {