From 712274d3728c99e10919420bbb0c25d010769c28 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 29 Jan 2011 09:31:48 -0800 Subject: [PATCH] Fixed commands. --- src/com/sk89q/util/commands/CommandContext.java | 2 +- src/com/sk89q/worldedit/WorldEdit.java | 2 +- .../sk89q/worldedit/bukkit/WorldEditPlugin.java | 2 +- .../worldedit/commands/ClipboardCommands.java | 2 +- .../sk89q/worldedit/commands/CommandsManager.java | 7 ++++--- .../worldedit/commands/ScriptingCommands.java | 3 +-- .../worldedit/commands/SelectionCommands.java | 14 +++++++------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/com/sk89q/util/commands/CommandContext.java b/src/com/sk89q/util/commands/CommandContext.java index 758b5b6eb..2fa930aa4 100644 --- a/src/com/sk89q/util/commands/CommandContext.java +++ b/src/com/sk89q/util/commands/CommandContext.java @@ -66,7 +66,7 @@ public class CommandContext { public String[] getPaddedSlice(int index, int padding) { String[] slice = new String[args.length - index + padding]; - System.arraycopy(args, index, slice, padding, args.length - index + padding); + System.arraycopy(args, index, slice, padding, args.length - index); return slice; } diff --git a/src/com/sk89q/worldedit/WorldEdit.java b/src/com/sk89q/worldedit/WorldEdit.java index 8e29e4756..dd38f1ce0 100644 --- a/src/com/sk89q/worldedit/WorldEdit.java +++ b/src/com/sk89q/worldedit/WorldEdit.java @@ -431,7 +431,7 @@ public class WorldEdit { } else if (dirStr.charAt(0) == 'd') { return CuboidClipboard.FlipDirection.UP_DOWN; } else { - throw new UnknownDirectionException(dirStr); + throw new UnknownDirectionException(dir.name()); } } diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 281b6e063..98ff2c9de 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -148,7 +148,7 @@ public class WorldEditPlugin extends JavaPlugin { public boolean onCommand(Player player, Command cmd, String commandLabel, String[] args) { if (cmd.getName().equalsIgnoreCase("reloadwe") - && hasPermission(player, "reloadwe")) { + && hasPermission(player, "worldedit.reload")) { try { loadConfiguration(); player.sendMessage("WorldEdit configuration reloaded."); diff --git a/src/com/sk89q/worldedit/commands/ClipboardCommands.java b/src/com/sk89q/worldedit/commands/ClipboardCommands.java index ed8bbb810..76f680ea8 100644 --- a/src/com/sk89q/worldedit/commands/ClipboardCommands.java +++ b/src/com/sk89q/worldedit/commands/ClipboardCommands.java @@ -106,7 +106,7 @@ public class ClipboardCommands { throws WorldEditException { boolean atOrigin = args.argsLength() > 0 - ? (args.getString(1).equalsIgnoreCase("true") + ? (args.getString(0).equalsIgnoreCase("true") || args.getString(0).equalsIgnoreCase("yes")) : false; diff --git a/src/com/sk89q/worldedit/commands/CommandsManager.java b/src/com/sk89q/worldedit/commands/CommandsManager.java index 31d83b36e..8711701a2 100644 --- a/src/com/sk89q/worldedit/commands/CommandsManager.java +++ b/src/com/sk89q/worldedit/commands/CommandsManager.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.commands; -import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; @@ -108,7 +107,7 @@ public class CommandsManager { */ public boolean execute(CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) - throws WorldEditException { + throws WorldEditException, Throwable { Method method = commands.get(args.getCommand().toLowerCase()); if (method == null) { @@ -140,8 +139,10 @@ public class CommandsManager { } catch (InvocationTargetException e) { if (e.getCause() instanceof WorldEditException) { throw (WorldEditException)e.getCause(); + } else if (e.getCause() instanceof NumberFormatException) { + throw (NumberFormatException)e.getCause(); } else { - e.printStackTrace(); + throw e.getCause(); } } diff --git a/src/com/sk89q/worldedit/commands/ScriptingCommands.java b/src/com/sk89q/worldedit/commands/ScriptingCommands.java index 7f1b6ef0c..b6cfa3420 100644 --- a/src/com/sk89q/worldedit/commands/ScriptingCommands.java +++ b/src/com/sk89q/worldedit/commands/ScriptingCommands.java @@ -69,8 +69,7 @@ public class ScriptingCommands { return; } - String[] scriptArgs = args.getPaddedSlice(0, 1); - scriptArgs[0] = lastScript; + String[] scriptArgs = args.getSlice(0); we.runScript(player, lastScript, scriptArgs); diff --git a/src/com/sk89q/worldedit/commands/SelectionCommands.java b/src/com/sk89q/worldedit/commands/SelectionCommands.java index 6d8523f2f..476274cc4 100644 --- a/src/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/com/sk89q/worldedit/commands/SelectionCommands.java @@ -195,7 +195,7 @@ public class SelectionCommands { @Command( aliases = {"//expand"}, - usage = " [[reverse-amount] ]", + usage = " [reverse-amount] ", desc = "Expand the selection area", min = 1, max = 3 @@ -207,13 +207,10 @@ public class SelectionCommands { Vector dir; - int change = args.getInteger(0); - int reverseChange = 0; - // Special syntax (//expand vert) to expand the selection between // sky and bedrock. - if (args.getString(0).equals("vert") - || args.getString(0).equals("vertical")) { + if (args.getString(0).equalsIgnoreCase("vert") + || args.getString(0).equalsIgnoreCase("vertical")) { Region region = session.getRegion(); int oldSize = region.getSize(); region.expand(new Vector(0, 128, 0)); @@ -225,6 +222,9 @@ public class SelectionCommands { return; } + + int change = args.getInteger(0); + int reverseChange = 0; // Specifying a direction if (args.argsLength() == 2) { @@ -369,7 +369,7 @@ public class SelectionCommands { throws WorldEditException { Set searchIDs = we.getBlockIDs(player, - args.getString(1), true); + args.getString(0), true); player.print("Counted: " + editSession.countBlocks(session.getRegion(), searchIDs)); }