Paper/Spigot-API-Patches/0054-PlayerAttemptPickupItemEvent.patch
Aikar 17b58d00d8
Unwrap Event Exceptions
This was a useless exception wrapper that ends up making
stack traces harder to read as well as the JVM cutting off
the important parts

Nothing catches this exception, so its safe to just get rid
of it and let the REAL exception bubble down
2019-02-23 12:17:41 -05:00

101 lines
2.6 KiB
Diff

From feb2578249055b5ea84eefea5352074314225f0d Mon Sep 17 00:00:00 2001
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
index 00000000..480293e9
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java
@@ -0,0 +1,85 @@
+package org.bukkit.event.player;
+
+import org.bukkit.entity.Item;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Thrown when a player attempts to pick an item up from the ground
+ */
+public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Item item;
+ private final int remaining;
+ private boolean flyAtPlayer = true;
+ private boolean isCancelled = false;
+
+ @Deprecated // Remove in 1.13
+ public PlayerAttemptPickupItemEvent(final Player player, final Item item) {
+ this(player, item, 0);
+ }
+
+ public PlayerAttemptPickupItemEvent(final Player player, final Item item, final int remaining) {
+ super(player);
+ this.item = item;
+ this.remaining = remaining;
+ }
+
+ /**
+ * Gets the Item attempted by the player.
+ *
+ * @return Item
+ */
+ public Item getItem() {
+ return item;
+ }
+
+ /**
+ * 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;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
--
2.20.1