From 96a290b153fd48819d3d60685d563e315ceda876 Mon Sep 17 00:00:00 2001 From: Redecouverte Date: Tue, 22 Feb 2011 13:22:06 +0100 Subject: [PATCH] added ItemAcquireBlacklistEvent for onPlayerPickupItem, not implemented in craftbukkit. yet --- .../bukkit/WorldGuardPlayerListener.java | 25 +++++++++++++++++++ .../worldguard/bukkit/WorldGuardPlugin.java | 1 + 2 files changed, 26 insertions(+) diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java index 4a3b4eb1..27cff8c4 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java @@ -19,6 +19,7 @@ package com.sk89q.worldguard.bukkit; +import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent; import org.bukkit.craftbukkit.entity.CraftItem; import org.bukkit.entity.Item; import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent; @@ -190,4 +191,28 @@ public void onPlayerDropItem(PlayerDropItemEvent event) { } } } + + /** + * Called when a player attempts to pickup an item + * + * @param event Relevant event details + */ + @Override + public void onPlayerPickupItem(PlayerPickupItemEvent event) { + + if (event.isCancelled()) { + return; + } + + if (plugin.blacklist != null) { + CraftItem ci = (CraftItem)event.getItem(); + + if (!plugin.blacklist.check(new ItemAcquireBlacklistEvent(plugin.wrapPlayer(event.getPlayer()), toVector(ci.getLocation()), + ci.getItemStack().getTypeId()), false, false)) { + event.setCancelled(true); + return; + } + } + } + } diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index 66b81d11..53f1aef5 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -205,6 +205,7 @@ private void registerEvents() { registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.High); registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.High); + registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener, Priority.High); registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal); registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal); registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal);