From 8e4558a246c63bf787eab8a08377f56e475b8880 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 9 Jan 2011 11:43:47 -0800 Subject: [PATCH] Updated Bukkit support. --- src/com/sk89q/worldedit/bukkit/BukkitPlayer.java | 2 +- .../sk89q/worldedit/bukkit/WorldEditBlockListener.java | 10 +++++----- src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 4753ae27b..44012117f 100644 --- a/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/src/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -46,7 +46,7 @@ public class BukkitPlayer extends LocalPlayer { @Override public int getItemInHand() { - ItemStack itemStack = player.getSelectedItem(); + ItemStack itemStack = player.getItemInHand(); return itemStack != null ? itemStack.getTypeID() : 0; } diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditBlockListener.java b/src/com/sk89q/worldedit/bukkit/WorldEditBlockListener.java index 84d8eaaa8..2c9b7b062 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditBlockListener.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditBlockListener.java @@ -23,6 +23,8 @@ import org.bukkit.Player; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockBrokenEvent; import org.bukkit.event.block.BlockPlacedEvent; +import org.bukkit.event.block.BlockRightClickedEvent; + import com.sk89q.worldedit.*; public class WorldEditBlockListener extends BlockListener { @@ -55,19 +57,17 @@ public class WorldEditBlockListener extends BlockListener { } /** - * Called when a player places a block + * Called when a player right clicks a block * * @param event Relevant event details */ - public void onBlockPlaced(BlockPlacedEvent event) { + public void onBlockRightClicked(BlockRightClickedEvent event) { LocalWorld world = new BukkitWorld(event.getBlock().getWorld()); WorldVector pos = new WorldVector(world, event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ()); LocalPlayer player = wrapPlayer(event.getPlayer()); - if (plugin.controller.handleBlockRightClick(player, pos)) { - event.setCancelled(true); - } + plugin.controller.handleBlockRightClick(player, pos); } private BukkitPlayer wrapPlayer(Player player) { diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 5e5931adc..7cce3cb27 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -76,7 +76,7 @@ public class WorldEditPlugin extends JavaPlugin { playerListener, Priority.Normal, this); getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); - getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACED, + getServer().getPluginManager().registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal, this); } }