Broadcast player pick up event before picking up item

This commit is contained in:
Shevchik 2014-01-08 08:30:36 +04:00
parent 6babf426e3
commit 30955db9b3

View File

@ -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,6 +87,9 @@ public class ChairEffects {
if (entity instanceof Item) {
if (p.getInventory().firstEmpty() != -1) {
Item item = (Item) entity;
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();
@ -96,6 +100,7 @@ public class ChairEffects {
}
}
}
}
},0,1);
}