2019-03-20 00:28:15 +00:00
|
|
|
From 75757b48a916e1c8b4d1dd2d543baae0526525e2 Mon Sep 17 00:00:00 2001
|
2017-06-12 00:46:11 +00:00
|
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Sun, 11 Jun 2017 16:30:37 -0500
|
|
|
|
Subject: [PATCH] PlayerAttemptPickupItemEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java
|
|
|
|
new file mode 100644
|
2019-03-20 00:28:15 +00:00
|
|
|
index 000000000..fb5cb3dc4
|
2017-06-12 00:46:11 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java
|
2019-03-20 00:28:15 +00:00
|
|
|
@@ -0,0 +1,89 @@
|
2017-06-12 00:46:11 +00:00
|
|
|
+package org.bukkit.event.player;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Item;
|
|
|
|
+import org.bukkit.entity.Player;
|
2017-11-11 03:49:53 +00:00
|
|
|
+import org.bukkit.event.Cancellable;
|
2017-06-12 00:46:11 +00:00
|
|
|
+import org.bukkit.event.HandlerList;
|
2019-03-20 00:28:15 +00:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2017-06-12 00:46:11 +00:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Thrown when a player attempts to pick an item up from the ground
|
|
|
|
+ */
|
2017-11-11 03:49:53 +00:00
|
|
|
+public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancellable {
|
2017-06-12 00:46:11 +00:00
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
2019-03-20 00:28:15 +00:00
|
|
|
+ @NotNull private final Item item;
|
2017-11-11 03:49:53 +00:00
|
|
|
+ private final int remaining;
|
|
|
|
+ private boolean flyAtPlayer = true;
|
|
|
|
+ private boolean isCancelled = false;
|
2017-06-12 00:46:11 +00:00
|
|
|
+
|
2019-03-20 00:28:15 +00:00
|
|
|
+ @Deprecated // Remove in 1.13 // Remove in 1.14?
|
|
|
|
+ public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item) {
|
2017-11-11 03:49:53 +00:00
|
|
|
+ this(player, item, 0);
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 00:28:15 +00:00
|
|
|
+ public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) {
|
2017-06-12 00:46:11 +00:00
|
|
|
+ super(player);
|
|
|
|
+ this.item = item;
|
2017-11-11 03:49:53 +00:00
|
|
|
+ this.remaining = remaining;
|
2017-06-12 00:46:11 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the Item attempted by the player.
|
|
|
|
+ *
|
|
|
|
+ * @return Item
|
|
|
|
+ */
|
2019-03-20 00:28:15 +00:00
|
|
|
+ @NotNull
|
2017-06-12 00:46:11 +00:00
|
|
|
+ public Item getItem() {
|
|
|
|
+ return item;
|
|
|
|
+ }
|
|
|
|
+
|
2017-11-11 03:49:53 +00:00
|
|
|
+ /**
|
|
|
|
+ * Gets the amount that will remain on the ground, if any
|
|
|
|
+ *
|
|
|
|
+ * @return amount that will remain on the ground
|
|
|
|
+ */
|
|
|
|
+ public int getRemaining() {
|
|
|
|
+ return remaining;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set if the item will fly at the player
|
|
|
|
+ * <p>Cancelling the event will set this value to false.</p>
|
|
|
|
+ *
|
|
|
|
+ * @param flyAtPlayer True for item to fly at player
|
|
|
|
+ */
|
|
|
|
+ public void setFlyAtPlayer(boolean flyAtPlayer) {
|
|
|
|
+ this.flyAtPlayer = flyAtPlayer;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets if the item will fly at the player
|
|
|
|
+ *
|
|
|
|
+ * @return True if the item will fly at the player
|
|
|
|
+ */
|
|
|
|
+ public boolean getFlyAtPlayer() {
|
|
|
|
+ return this.flyAtPlayer;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return this.isCancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ this.isCancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 00:28:15 +00:00
|
|
|
+ @NotNull
|
2017-06-12 00:46:11 +00:00
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 00:28:15 +00:00
|
|
|
+ @NotNull
|
2017-06-12 00:46:11 +00:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2019-03-20 00:28:15 +00:00
|
|
|
2.21.0
|
2017-06-12 00:46:11 +00:00
|
|
|
|