Class PlayerPickItemEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.papermc.paper.event.player.PlayerPickItemEvent
All Implemented Interfaces:
Cancellable

public class PlayerPickItemEvent extends PlayerEvent implements Cancellable
Event that is fired when a player uses the pick item functionality (middle-clicking a block to get the appropriate item). However, note that this event will only trigger if an item has to be moved from the inventory to the hotbar. After the handling of this event, the contents of the source and the target slot will be swapped and the currently selected hotbar slot of the player will be set to the target slot.

Note: This event will not be fired for players in creative mode.

  • Constructor Details

  • Method Details

    • getTargetSlot

      public @org.jetbrains.annotations.Range(from=0L, to=8L) int getTargetSlot()
      Returns the slot the item that is being picked goes into.
      Returns:
      hotbar slot (0-8 inclusive)
    • setTargetSlot

      public void setTargetSlot(@org.jetbrains.annotations.Range(from=0L, to=8L) int targetSlot)
      Changes the slot the item that is being picked goes into.
      Parameters:
      targetSlot - hotbar slot (0-8 inclusive)
    • getSourceSlot

      public @org.jetbrains.annotations.Range(from=0L, to=35L) int getSourceSlot()
      Returns the slot in which the item that will be put into the players hotbar is located.
      Returns:
      player inventory slot (0-35 inclusive)
    • setSourceSlot

      public void setSourceSlot(@org.jetbrains.annotations.Range(from=0L, to=35L) int sourceSlot)
      Change the source slot from which the item that will be put in the players hotbar will be taken.
      Parameters:
      sourceSlot - player inventory slot (0-35 inclusive)
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if this event is cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()