From 30955db9b37af57d87b26c6cf5b6c087d8f2e7b2 Mon Sep 17 00:00:00 2001 From: Shevchik Date: Wed, 8 Jan 2014 08:30:36 +0400 Subject: [PATCH] Broadcast player pick up event before picking up item --- src/com/cnaude/chairs/ChairEffects.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/cnaude/chairs/ChairEffects.java b/src/com/cnaude/chairs/ChairEffects.java index 5e96340..a3c2157 100644 --- a/src/com/cnaude/chairs/ChairEffects.java +++ b/src/com/cnaude/chairs/ChairEffects.java @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerPickupItemEvent; /** * @@ -86,9 +87,13 @@ public class ChairEffects { if (entity instanceof Item) { if (p.getInventory().firstEmpty() != -1) { Item item = (Item) entity; - if (item.getPickupDelay() == 0) { - p.getInventory().addItem(item.getItemStack()); - entity.remove(); + PlayerPickupItemEvent pickupevent = new PlayerPickupItemEvent(p, item, 0); + Bukkit.getPluginManager().callEvent(pickupevent); + if (!pickupevent.isCancelled()) { + if (item.getPickupDelay() == 0) { + p.getInventory().addItem(item.getItemStack()); + entity.remove(); + } } } }