Package io.papermc.paper.event.player
Class PlayerPickItemEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.papermc.paper.event.player.PlayerPickItemEvent
- All Implemented Interfaces:
Cancellable
- Direct Known Subclasses:
PlayerPickBlockEvent,PlayerPickEntityEvent
Event that is fired when a player uses the pick item functionality
(middle-clicking a
block
or entity to get the appropriate item).
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.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPlayerPickItemEvent(Player player, boolean includeData, int targetSlot, int sourceSlot) -
Method Summary
Modifier and TypeMethodDescriptionstatic HandlerList@org.jetbrains.annotations.Range(from=-1L, to=35L) intReturns the slot in which the item that will be put into the players hotbar is located.@org.jetbrains.annotations.Range(from=0L, to=8L) intReturns the slot the item that is being picked goes into.booleanGets the cancellation state of this event.booleanChecks whether the player wants block/entity data included.voidsetCancelled(boolean cancel) Sets the cancellation state of this event.voidsetSourceSlot(@org.jetbrains.annotations.Range(from=-1L, to=35L) int sourceSlot) Change the source slot from which the item that will be put in the players hotbar will be taken.voidsetTargetSlot(@org.jetbrains.annotations.Range(from=0L, to=8L) int targetSlot) Changes the slot the item that is being picked goes into.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayerMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PlayerPickItemEvent
-
-
Method Details
-
isIncludeData
public boolean isIncludeData()Checks whether the player wants block/entity data included.- Returns:
trueif data is included, otherwisefalse.
-
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=-1L, to=35L) int getSourceSlot()Returns the slot in which the item that will be put into the players hotbar is located.Returns
-1if the item is not in the player's inventory. If this is the case and the player is in creative mode, the item will be spawned in.- Returns:
- player inventory slot (0-35 inclusive, or
-1if not in the player inventory)
-
setSourceSlot
public void setSourceSlot(@org.jetbrains.annotations.Range(from=-1L, to=35L) int sourceSlot) Change the source slot from which the item that will be put in the players hotbar will be taken.If set to
-1and the player is in creative mode, the item will be spawned in.- Parameters:
sourceSlot- player inventory slot (0-35 inclusive, or-1if not in the player inventory)
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableGets 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:
isCancelledin interfaceCancellable- Returns:
trueif this event is cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableSets 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:
setCancelledin interfaceCancellable- Parameters:
cancel-trueif you wish to cancel this event
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getHandlerList
-