mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-18 12:48:53 +01:00
Fixup PlayerPickItemEvent docs more
This commit is contained in:
parent
77afb9aa78
commit
346b9b8d2d
1 changed files with 10 additions and 12 deletions
|
@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerPickItemEvent
|
|||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPickItemEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPickItemEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e9b968ebd771b9d4c94d7b219ea2b68c1f871733
|
||||
index 0000000000000000000000000000000000000000..7de240399f3ae069c496add9f0d437a41ed8f58d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerPickItemEvent.java
|
||||
@@ -0,0 +1,97 @@
|
||||
@@ -0,0 +1,95 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
|
@ -22,12 +22,9 @@ index 0000000000000000000000000000000000000000..e9b968ebd771b9d4c94d7b219ea2b68c
|
|||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * 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.
|
||||
+ * <p>
|
||||
+ * Note: This event will not be fired for players in creative mode.
|
||||
+ * 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.
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class PlayerPickItemEvent extends PlayerEvent implements Cancellable {
|
||||
|
@ -68,9 +65,10 @@ index 0000000000000000000000000000000000000000..e9b968ebd771b9d4c94d7b219ea2b68c
|
|||
+ /**
|
||||
+ * Returns the slot in which the item that will be put into the players hotbar is located.
|
||||
+ * <p>
|
||||
+ * Returns {@code -1} if the item is not in the player's inventory and should be spawned in if in creative mode.
|
||||
+ * Returns {@code -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.
|
||||
+ *
|
||||
+ * @return player inventory slot (0-35 inclusive, or {@code -1} not taken from the inventory)
|
||||
+ * @return player inventory slot (0-35 inclusive, or {@code -1} if not in the player inventory)
|
||||
+ */
|
||||
+ public @Range(from = -1, to = 35) int getSourceSlot() {
|
||||
+ return this.sourceSlot;
|
||||
|
@ -81,10 +79,10 @@ index 0000000000000000000000000000000000000000..e9b968ebd771b9d4c94d7b219ea2b68c
|
|||
+ * <p>
|
||||
+ * If set to {@code -1} and the player is in creative mode, the item will be spawned in.
|
||||
+ *
|
||||
+ * @param sourceSlot player inventory slot (0-35 inclusive, or {@code -1} not taken from the inventory)
|
||||
+ * @param sourceSlot player inventory slot (0-35 inclusive, or {@code -1} if not in the player inventory)
|
||||
+ */
|
||||
+ public void setSourceSlot(final @Range(from = -1, to = 35) int sourceSlot) {
|
||||
+ Preconditions.checkArgument(sourceSlot >= -1 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot");
|
||||
+ Preconditions.checkArgument(sourceSlot >= -1 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot, or -1");
|
||||
+ this.sourceSlot = sourceSlot;
|
||||
+ }
|
||||
+
|
||||
|
|
Loading…
Reference in a new issue