Class PlayerPreEatEvent

java.lang.Object
net.minestom.server.event.Event
net.minestom.server.event.CancellableEvent
net.minestom.server.event.player.PlayerPreEatEvent

public class PlayerPreEatEvent
extends CancellableEvent
Called before the PlayerEatEvent and can be used to change the eating time or to cancel its processing, cancelling the event means that the player will continue the animation indefinitely.
  • Constructor Summary

    Constructors 
    Constructor Description
    PlayerPreEatEvent​(Player player, ItemStack foodItem, long eatingTime)  
  • Method Summary

    Modifier and Type Method Description
    long getEatingTime()
    Gets the food eating time.
    ItemStack getFoodItem()
    The food item which will be eaten.
    Player getPlayer()
    The player who is trying to eat.
    void setEatingTime​(long eatingTime)
    Changes the food eating time.

    Methods inherited from class net.minestom.server.event.CancellableEvent

    isCancelled, setCancelled

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getPlayer

      @NotNull public Player getPlayer()
      The player who is trying to eat.
      Returns:
      the concerned player
    • getFoodItem

      @NotNull public ItemStack getFoodItem()
      The food item which will be eaten.
      Returns:
      the food item
    • getEatingTime

      public long getEatingTime()
      Gets the food eating time.

      This is by default Player.getDefaultEatingTime().

      Returns:
      the eating time
    • setEatingTime

      public void setEatingTime​(long eatingTime)
      Changes the food eating time.
      Parameters:
      eatingTime - the new eating time