Package net.minestom.server.event.player
Class PlayerUseItemEvent
java.lang.Object
net.minestom.server.event.player.PlayerUseItemEvent
- All Implemented Interfaces:
Event
,CancellableEvent
,EntityEvent
,EntityInstanceEvent
,InstanceEvent
,ItemEvent
,PlayerEvent
,PlayerInstanceEvent
public class PlayerUseItemEvent
extends Object
implements PlayerInstanceEvent, ItemEvent, CancellableEvent
Event when an item is used without clicking on a block.
-
Constructor Summary
ConstructorDescriptionPlayerUseItemEvent
(@NotNull Player player, @NotNull PlayerHand hand, @NotNull ItemStack itemStack, long itemUseTime) -
Method Summary
Modifier and TypeMethodDescription@NotNull PlayerHand
getHand()
Gets which hand the player used.@NotNull ItemStack
Gets the item which has been used.long
Gets the item usage duration.@NotNull Player
Gets the player.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
setItemUseTime
(long itemUseTime) Changes the item usage duration.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
-
PlayerUseItemEvent
public PlayerUseItemEvent(@NotNull @NotNull Player player, @NotNull @NotNull PlayerHand hand, @NotNull @NotNull ItemStack itemStack, long itemUseTime)
-
-
Method Details
-
getHand
Gets which hand the player used.- Returns:
- the hand used
-
getItemStack
Gets the item which has been used.- Specified by:
getItemStack
in interfaceItemEvent
- Returns:
- the item
-
getItemUseTime
public long getItemUseTime()Gets the item usage duration. After this amount of milliseconds, the animation will stop automatically andPlayerFinishItemUseEvent
is called.- Returns:
- the item use time
-
setItemUseTime
public void setItemUseTime(long itemUseTime) Changes the item usage duration.- Parameters:
itemUseTime
- the new item use time
-
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 cancel) Description copied from interface:CancellableEvent
Marks theEvent
as cancelled or not.- Specified by:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancel
- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEvent
Gets the player.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player
-