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()
long
Returns the item use duration, in ticks.Gets the player.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancelled) Marks theEvent
as cancelled or not.void
setItemUseDuration
(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, wait
Methods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstance
Methods inherited from interface net.minestom.server.event.trait.PlayerEvent
getEntity
-
Constructor Details
-
PlayerBeginItemUseEvent
public PlayerBeginItemUseEvent(Player player, PlayerHand hand, ItemStack itemStack, ItemAnimation animation, long itemUseDuration)
-
-
Method Details
-
getPlayer
Description copied from interface:PlayerEvent
Gets the player.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player
-
getHand
-
getItemStack
- Specified by:
getItemStack
in 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:CancellableEvent
Gets if theEvent
should be cancelled or not.- Specified by:
isCancelled
in interfaceCancellableEvent
- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancelled) Description copied from interface:CancellableEvent
Marks theEvent
as cancelled or not.- Specified by:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancelled
- true if the event should be cancelled, false otherwise
-