Changed how the player item event was handled.

This commit is contained in:
sk89q 2011-01-19 22:09:15 -08:00
parent 194108336b
commit 627de1aebd

View File

@ -117,8 +117,9 @@ public void onPlayerQuit(PlayerEvent event) {
public void onPlayerItem(PlayerItemEvent event) { public void onPlayerItem(PlayerItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
ItemStack item = event.getItem();
if (plugin.useRegions && !event.isBlock() && event.getBlockClicked() != null) { if (plugin.useRegions && !event.isBlock() && block != null) {
Vector pt = toVector(block.getRelative(event.getBlockFace())); Vector pt = toVector(block.getRelative(event.getBlockFace()));
LocalPlayer localPlayer = plugin.wrapPlayer(player); LocalPlayer localPlayer = plugin.wrapPlayer(player);
@ -131,10 +132,11 @@ public void onPlayerItem(PlayerItemEvent event) {
} }
} }
if (block != null && plugin.blacklist != null) { if (item != null && plugin.blacklist != null && block != null) {
if (!plugin.blacklist.check( if (!plugin.blacklist.check(
new ItemUseBlacklistEvent(plugin.wrapPlayer(player), toVector(block), new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
block.getTypeId()), false, false)) { toVector(block.getRelative(event.getBlockFace())),
item.getTypeId()), false, false)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }