All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bukkit.event.entity.FoodLevelChangeEvent Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package org.bukkit.event.entity;

import org.bukkit.entity.HumanEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
 * Called when a human entity's food level changes
 */
public class FoodLevelChangeEvent extends EntityEvent implements Cancellable {
  private static final HandlerList handlers = new HandlerList();
  private boolean cancel = false;
  private int level;

  public FoodLevelChangeEvent(final HumanEntity what, final int level) {
    super(what);
    this.level = level;
  }

  public static HandlerList getHandlerList() {
    return handlers;
  }

  @Override
  public HumanEntity getEntity() {
    return (HumanEntity) entity;
  }

  /**
   * Gets the resultant food level that the entity involved in this event
   * should be set to.
   * 

* 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; } @Override public HandlerList getHandlers() { return handlers; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy