diff --git a/src/WorldGuard.java b/src/WorldGuard.java index 89adb145..be700de2 100644 --- a/src/WorldGuard.java +++ b/src/WorldGuard.java @@ -61,6 +61,8 @@ public void initialize() { PluginListener.Priority.HIGH); loader.addListener(PluginLoader.Hook.DISCONNECT, listener, this, PluginListener.Priority.HIGH); + loader.addListener(PluginLoader.Hook.ITEM_DROP , listener, this, + PluginListener.Priority.HIGH); } /** diff --git a/src/WorldGuardListener.java b/src/WorldGuardListener.java index 5fe91c63..a3400871 100644 --- a/src/WorldGuardListener.java +++ b/src/WorldGuardListener.java @@ -67,6 +67,7 @@ public class WorldGuardListener extends PluginListener { private boolean blockLagFix; private Set fireNoSpreadBlocks; private Set allowedLavaSpreadOver; + private Set itemDropBlacklist; private boolean classicWater; private Map blacklist; @@ -113,6 +114,7 @@ public void loadConfiguration() { blockLighter = properties.getBoolean("block-lighter", false); preventLavaFire = properties.getBoolean("disable-lava-fire", false); disableAllFire = properties.getBoolean("disable-all-fire-spread", false); + itemDropBlacklist = toBlockIDSet(properties.getString("item-drop-blacklist", "")); fireNoSpreadBlocks = toBlockIDSet(properties.getString("disallowed-fire-spread-blocks", "")); allowedLavaSpreadOver = toBlockIDSet(properties.getString("allowed-lava-spread-blocks", "")); classicWater = properties.getBoolean("classic-water", false); @@ -175,6 +177,27 @@ public String onLoginChecks(String user) { return null; } + + /** + * Called when a player drops an item. + * + * @param player + * player who dropped the item + * @param item + * item that was dropped + * @return true if you don't want the dropped item to be spawned in the + * world + */ + public boolean onItemDrop(Player player, Item item) { + if (itemDropBlacklist.isEmpty()) return false; + + int n = item.getItemId(); + if (itemDropBlacklist.contains(n)) { + player.sendMessage(Colors.Rose+"Item was destroyed!"); + return true; + } + return false; + } /** * Called when someone presses right click. If they right clicked with a