Fixed commands.

This commit is contained in:
sk89q 2011-01-29 09:31:48 -08:00
parent f683959420
commit 712274d372
7 changed files with 16 additions and 16 deletions

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -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.");

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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);

View File

@ -195,7 +195,7 @@ public class SelectionCommands {
@Command(
aliases = {"//expand"},
usage = "<amount> [[reverse-amount] <direction>]",
usage = "<amount> [reverse-amount] <direction>",
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<Integer> searchIDs = we.getBlockIDs(player,
args.getString(1), true);
args.getString(0), true);
player.print("Counted: " +
editSession.countBlocks(session.getRegion(), searchIDs));
}