Package net.minestom.server.event.item
Class PlayerBeginItemUseEvent
java.lang.Object
net.minestom.server.event.item.PlayerBeginItemUseEvent
- All Implemented Interfaces:
Event,CancellableEvent,EntityEvent,EntityInstanceEvent,InstanceEvent,ItemEvent,PlayerEvent,PlayerInstanceEvent
public class PlayerBeginItemUseEvent
extends Object
implements PlayerInstanceEvent, ItemEvent, CancellableEvent
Called when a player begins using an item with the item, animation, and duration.
Setting the use duration to zero or cancelling the event will prevent consumption.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerBeginItemUseEvent(@NotNull Player player, @NotNull PlayerHand hand, @NotNull ItemStack itemStack, @NotNull ItemAnimation animation, long itemUseDuration) -
Method Summary
Modifier and TypeMethodDescription@NotNull ItemAnimation@NotNull PlayerHandgetHand()@NotNull ItemStacklongReturns the item use duration, in ticks.@NotNull PlayerGets the player.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancelled) Marks theEventas cancelled or not.voidsetItemStack(@NotNull ItemStack itemStack) voidsetItemUseDuration(long itemUseDuration) Sets the item use duration, in ticks.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstanceMethods inherited from interface net.minestom.server.event.trait.PlayerEvent
getEntity
-
Constructor Details
-
PlayerBeginItemUseEvent
public PlayerBeginItemUseEvent(@NotNull @NotNull Player player, @NotNull @NotNull PlayerHand hand, @NotNull @NotNull ItemStack itemStack, @NotNull @NotNull ItemAnimation animation, long itemUseDuration)
-
-
Method Details
-
getPlayer
Description copied from interface:PlayerEventGets the player.- Specified by:
getPlayerin interfacePlayerEvent- Returns:
- the player
-
getHand
-
getItemStack
- Specified by:
getItemStackin interfaceItemEvent
-
setItemStack
-
getAnimation
-
getItemUseDuration
public long getItemUseDuration()Returns the item use duration, in ticks. A duration of zero will prevent consumption (same effect as cancellation).- Returns:
- the current item use duration
-
setItemUseDuration
public void setItemUseDuration(long itemUseDuration) Sets the item use duration, in ticks. -
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:CancellableEventMarks theEventas cancelled or not.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancelled- true if the event should be cancelled, false otherwise
-