From c2460a6305ec4b747cb0088f75bc30123abb4d9f Mon Sep 17 00:00:00 2001 From: zml2008 Date: Tue, 6 Dec 2011 07:45:07 -0800 Subject: [PATCH] PlayerInteract listener should now respect cancelled status. --- .../worldedit/bukkit/WorldEditPlayerListener.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java index dfb3e134d..10dc45fe3 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.event.Event; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerListener; @@ -66,7 +67,7 @@ public class WorldEditPlayerListener extends PlayerListener { */ @Override public void onPlayerQuit(PlayerQuitEvent event) { - plugin.getWorldEdit().markExpire(wrapPlayer(event.getPlayer())); + plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer())); } /** @@ -82,7 +83,7 @@ public class WorldEditPlayerListener extends PlayerListener { String[] split = event.getMessage().split(" "); - if (plugin.getWorldEdit().handleCommand(wrapPlayer(event.getPlayer()), split)) { + if (plugin.getWorldEdit().handleCommand(plugin.wrapPlayer(event.getPlayer()), split)) { event.setCancelled(true); } } @@ -96,7 +97,11 @@ public class WorldEditPlayerListener extends PlayerListener { */ @Override public void onPlayerInteract(PlayerInteractEvent event) { - final LocalPlayer player = wrapPlayer(event.getPlayer()); + if (event.useItemInHand() == Event.Result.DENY) { + return; + } + + final LocalPlayer player = plugin.wrapPlayer(event.getPlayer()); final LocalWorld world = player.getWorld(); final WorldEdit we = plugin.getWorldEdit(); @@ -162,8 +167,4 @@ public class WorldEditPlayerListener extends PlayerListener { break; } } - - private BukkitPlayer wrapPlayer(Player player) { - return new BukkitPlayer(plugin, plugin.getServerInterface(), player); - } }