Package net.minestom.server.event.player
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.
-
Constructor Details
-
Method Details
-
getPlayer
The player who is trying to eat.- Returns:
- the concerned player
-
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
-