added ItemAcquireBlacklistEvent for onPlayerPickupItem, not implemented in craftbukkit. yet

This commit is contained in:
Redecouverte 2011-02-22 13:22:06 +01:00
parent 912fcfe88a
commit 96a290b153
2 changed files with 26 additions and 0 deletions

View File

@ -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;
}
}
}
}

View File

@ -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);