PlayerInteract listener should now respect cancelled status.

This commit is contained in:
zml2008 2011-12-06 07:45:07 -08:00
parent d69863db59
commit c2460a6305

View File

@ -22,6 +22,7 @@
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
@ -66,7 +67,7 @@ public WorldEditPlayerListener(WorldEditPlugin plugin) {
*/ */
@Override @Override
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
plugin.getWorldEdit().markExpire(wrapPlayer(event.getPlayer())); plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
} }
/** /**
@ -82,7 +83,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String[] split = event.getMessage().split(" "); 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); event.setCancelled(true);
} }
} }
@ -96,7 +97,11 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
*/ */
@Override @Override
public void onPlayerInteract(PlayerInteractEvent event) { 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 LocalWorld world = player.getWorld();
final WorldEdit we = plugin.getWorldEdit(); final WorldEdit we = plugin.getWorldEdit();
@ -162,8 +167,4 @@ public void run() {
break; break;
} }
} }
private BukkitPlayer wrapPlayer(Player player) {
return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
}
} }