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
ConstructorsModifierConstructorDescriptionprotected
PlayerPickItemEvent
(Player player, boolean includeData, int targetSlot, int sourceSlot) -
Method Summary
Modifier and TypeMethodDescriptionstatic HandlerList
@org.jetbrains.annotations.Range(from=-1L, to=35L) int
Returns the slot in which the item that will be put into the players hotbar is located.@org.jetbrains.annotations.Range(from=0L, to=8L) int
Returns the slot the item that is being picked goes into.boolean
Gets the cancellation state of this event.boolean
Checks whether the player wants block/entity data included.void
setCancelled
(boolean cancel) Sets the cancellation state of this event.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.void
setTargetSlot
(@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
getPlayer
Methods 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:
true
if 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
-1
if 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
-1
if 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
-1
and the player is in creative mode, the item will be spawned in.- Parameters:
sourceSlot
- player inventory slot (0-35 inclusive, or-1
if not in the player inventory)
-
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 interfaceCancellable
- 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 interfaceCancellable
- Parameters:
cancel
-true
if you wish to cancel this event
-
getHandlers
- Specified by:
getHandlers
in classEvent
-
getHandlerList
-