mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
PlayerAttemptPickupItemEvent (#732)
This commit is contained in:
parent
899f4969c1
commit
a86bd09bb7
2 changed files with 81 additions and 0 deletions
49
Spigot-API-Patches/PlayerAttemptPickupItemEvent.patch
Normal file
49
Spigot-API-Patches/PlayerAttemptPickupItemEvent.patch
Normal file
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 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..2f5fdb13
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package org.bukkit.event.player;
|
||||
+
|
||||
+import org.bukkit.entity.Item;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+
|
||||
+/**
|
||||
+ * Thrown when a player attempts to pick an item up from the ground
|
||||
+ */
|
||||
+public class PlayerAttemptPickupItemEvent extends PlayerEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Item item;
|
||||
+
|
||||
+ public PlayerAttemptPickupItemEvent(final Player player, final Item item) {
|
||||
+ super(player);
|
||||
+ this.item = item;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the Item attempted by the player.
|
||||
+ *
|
||||
+ * @return Item
|
||||
+ */
|
||||
+ public Item getItem() {
|
||||
+ return item;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
--
|
32
Spigot-Server-Patches/PlayerAttemptPickupItemEvent.patch
Normal file
32
Spigot-Server-Patches/PlayerAttemptPickupItemEvent.patch
Normal file
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 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 95ca1b8e..8820dd32 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
@@ -0,0 +0,0 @@ import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
+import org.bukkit.event.player.PlayerAttemptPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent; // CraftBukkit
|
||||
import com.destroystokyo.paper.HopperPusher; // Paper
|
||||
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
--
|
Loading…
Reference in a new issue