Added workaround for tool lookup of double chests

This commit is contained in:
Robin Kupper
2011-06-21 21:23:52 +02:00
parent 9ab5e4aee2
commit 88048c15d8
2 changed files with 27 additions and 8 deletions
+18 -4
View File
@@ -2,13 +2,17 @@ package de.diddiz.LogBlock;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
class LBToolListener extends PlayerListener
{
private final static BlockFace[] orientations = {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
private final CommandsHandler handler;
private final LogBlock logblock;
private final int toolID;
@@ -33,14 +37,24 @@ class LBToolListener extends PlayerListener
final Session session = logblock.getSession(player.getName());
if (type == toolID && session.toolEnabled && logblock.hasPermission(player, "logblock.tool") || type == toolblockID && session.toolBlockEnabled && logblock.hasPermission(player, "logblock.toolblock"))
if (tables.get(player.getWorld().getName().hashCode()) != null) {
if (!(type == toolID && event.getClickedBlock().getTypeId() == 26))
final Block block = event.getClickedBlock();
if (!(type == toolID && block.getTypeId() == 26))
event.setCancelled(true);
final QueryParams params = type == toolID ? session.toolQuery : session.toolBlockQuery;
final ToolMode mode = type == toolID ? session.toolMode : session.toolBlockMode;
params.loc = null;
params.sel = null;
if (type == toolblockID && action == Action.RIGHT_CLICK_BLOCK)
params.setLocation(event.getClickedBlock().getFace(event.getBlockFace()).getLocation());
else
params.setLocation(event.getClickedBlock().getLocation());
params.setLocation(block.getFace(event.getBlockFace()).getLocation());
else if (event.getClickedBlock().getTypeId() != 54)
params.setLocation(block.getLocation());
else {
for (final BlockFace face : orientations)
if (block.getFace(face).getTypeId() == 54)
params.setSelection(new CuboidSelection(player.getWorld(), block.getLocation(), block.getFace(face).getLocation()));
if (params.sel == null)
params.setLocation(block.getLocation());
}
try {
if (mode == ToolMode.ROLLBACK)
handler.new CommandRollback(player, params, true);
+9 -4
View File
@@ -249,12 +249,12 @@ public class QueryParams implements Cloneable
final Plugin we = player.getServer().getPluginManager().getPlugin("WorldEdit");
if (we == null)
throw new IllegalArgumentException("WorldEdit plugin not found");
sel = ((WorldEditPlugin)we).getSelection(player);
if (sel == null)
final Selection selection = ((WorldEditPlugin)we).getSelection(player);
if (selection == null)
throw new IllegalArgumentException("No selection defined");
if (!(sel instanceof CuboidSelection))
if (!(selection instanceof CuboidSelection))
throw new IllegalArgumentException("You have to define a cuboid selection");
world = sel.getWorld();
setSelection(selection);
} else if (param.equals("time") || param.equals("since")) {
if (values == null)
minutes = logblock.getConfig().defaultTime;
@@ -341,6 +341,11 @@ public class QueryParams implements Cloneable
world = loc.getWorld();
}
public void setSelection(Selection sel) {
this.sel = sel;
world = sel.getWorld();
}
public void setPlayer(String playerName) {
players.clear();
players.add(playerName);