PaperMC/Spigot-Server-Patches/0214-PlayerAttemptPickupItemEvent.patch
2017-10-06 04:39:34 +01:00

34 lines
1.5 KiB
Diff

From 5259d5af8c2d7a9357333588950b955ed4312eca Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sun, 11 Jun 2017 16:30:30 -0500
Subject: [PATCH] PlayerAttemptPickupItemEvent
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index ae4910b4b..b56d1a35e 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
// CraftBukkit end
+import org.bukkit.event.player.PlayerAttemptPickupItemEvent; // Paper
import com.destroystokyo.paper.HopperPusher; // Paper
// Paper start - implement HopperPusher
@@ -329,6 +330,12 @@ public class EntityItem extends Entity implements HopperPusher {
Item item = itemstack.getItem();
int i = itemstack.getCount();
+ // Paper start
+ if (this.pickupDelay <= 0) {
+ this.world.getServer().getPluginManager().callEvent(new PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity()));
+ }
+ // Paper end
+
// CraftBukkit start - fire PlayerPickupItemEvent
int canHold = entityhuman.inventory.canHold(itemstack);
int remaining = i - canHold;
--
2.14.2