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 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

      @NotNull public @NotNull Player getPlayer()
      Description copied from interface: PlayerEvent
      Gets the player.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player
    • getHand

      @NotNull public @NotNull PlayerHand getHand()
    • getItemStack

      @NotNull public @NotNull ItemStack getItemStack()
      Specified by:
      getItemStack in interface ItemEvent
    • getAnimation

      @NotNull public @NotNull ItemAnimation 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 the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancelled)
      Description copied from interface: CancellableEvent
      Marks the Event as cancelled or not.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancelled - true if the event should be cancelled, false otherwise