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(Player player, PlayerHand hand, ItemStack itemStack, ItemAnimation animation, long itemUseDuration) -
Method Summary
Modifier and TypeMethodDescriptiongetHand()longReturns the item use duration, in ticks.Gets the player.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancelled) Marks theEventas cancelled or not.voidsetItemUseDuration(long itemUseDuration) Sets the item use duration, in ticks.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EntityInstanceEvent
getInstanceMethods inherited from interface PlayerEvent
getEntity
-
Constructor Details
-
PlayerBeginItemUseEvent
public PlayerBeginItemUseEvent(Player player, PlayerHand hand, ItemStack itemStack, 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
-
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
-