Paper/Spigot-Server-Patches/0214-PlayerAttemptPickupItemEvent.patch

45 lines
1.8 KiB
Diff
Raw Normal View History

From 45b4de7a63937ed0c9c58960e6be049d11b00a52 Mon Sep 17 00:00:00 2001
2017-06-12 02:46:11 +02:00
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..0b7fc327f 100644
2017-06-12 02:46:11 +02:00
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
2017-07-28 15:45:16 +02:00
@@ -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
2017-06-12 02:46:11 +02:00
import com.destroystokyo.paper.HopperPusher; // Paper
2017-07-28 15:45:16 +02:00
// Paper start - implement HopperPusher
2017-11-11 04:49:53 +01:00
@@ -334,6 +335,22 @@ public class EntityItem extends Entity implements HopperPusher {
int remaining = i - canHold;
boolean flyAtPlayer = false; // Paper
2017-06-12 02:46:11 +02:00
+ // Paper start
+ if (this.pickupDelay <= 0) {
2017-11-11 04:49:53 +01:00
+ PlayerAttemptPickupItemEvent attemptEvent = new PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ this.world.getServer().getPluginManager().callEvent(attemptEvent);
+
+ flyAtPlayer = attemptEvent.getFlyAtPlayer();
+ if (attemptEvent.isCancelled()) {
+ if (flyAtPlayer) {
+ entityhuman.receive(this, i);
+ }
+
+ return;
+ }
2017-06-12 02:46:11 +02:00
+ }
+ // Paper end
+
2017-11-11 04:49:53 +01:00
if (this.pickupDelay <= 0 && canHold > 0) {
itemstack.setCount(canHold);
// Call legacy event
2017-06-12 02:46:11 +02:00
--
2.18.0
2017-06-12 02:46:11 +02:00