summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2017-07-28 17:47:51 +1000
committermd_5 <git@md-5.net>2017-07-28 17:47:51 +1000
commit1b414f02478971d8918d8a07149e0db6b5a596a0 (patch)
tree2a753c3817324ca544e9cf70edbc805da7691991
parent650f5090d6dee8e7921eb55f43bf4ccee4470e82 (diff)
downloadbukkit-1b414f02478971d8918d8a07149e0db6b5a596a0.tar
bukkit-1b414f02478971d8918d8a07149e0db6b5a596a0.tar.gz
bukkit-1b414f02478971d8918d8a07149e0db6b5a596a0.tar.lz
bukkit-1b414f02478971d8918d8a07149e0db6b5a596a0.tar.xz
bukkit-1b414f02478971d8918d8a07149e0db6b5a596a0.zip
SPIGOT-3403: Add an EntityPickupItemEvent
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java62
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java3
2 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java b/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java
new file mode 100644
index 00000000..20f2d538
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java
@@ -0,0 +1,62 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.entity.Item;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Thrown when a entity picks an item up from the ground
+ */
+public class EntityPickupItemEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Item item;
+ private boolean cancel = false;
+ private final int remaining;
+
+ public EntityPickupItemEvent(final LivingEntity entity, final Item item, final int remaining) {
+ super(entity);
+ this.item = item;
+ this.remaining = remaining;
+ }
+
+ @Override
+ public LivingEntity getEntity() {
+ return (LivingEntity) entity;
+ }
+
+ /**
+ * Gets the Item picked up by the entity.
+ *
+ * @return Item
+ */
+ public Item getItem() {
+ return item;
+ }
+
+ /**
+ * Gets the amount remaining on the ground, if any
+ *
+ * @return amount remaining on the ground
+ */
+ public int getRemaining() {
+ return remaining;
+ }
+
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
index dfba8163..29f03f5d 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
@@ -4,10 +4,13 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityPickupItemEvent;
/**
* Thrown when a player picks an item up from the ground
+ * @deprecated {@link EntityPickupItemEvent}
*/
+@Deprecated
public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Item item;