From 697970466179e164e9ac54de4e31205863090079 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 30 Jan 2011 22:14:36 -0800 Subject: [PATCH] Fixed /removenear not taking a default size argument. --- src/com/sk89q/util/commands/CommandContext.java | 12 ++++++++++++ .../sk89q/worldedit/commands/UtilityCommands.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/sk89q/util/commands/CommandContext.java b/src/com/sk89q/util/commands/CommandContext.java index 0b6c64cee..82744aba4 100644 --- a/src/com/sk89q/util/commands/CommandContext.java +++ b/src/com/sk89q/util/commands/CommandContext.java @@ -61,6 +61,10 @@ public class CommandContext { public String getString(int index) { return args[index + 1]; } + + public String getString(int index, String def) { + return index + 1 < args.length ? args[index + 1] : def; + } public String getJoinedStrings(int initialIndex) { initialIndex = initialIndex + 1; @@ -75,10 +79,18 @@ public class CommandContext { return Integer.parseInt(args[index + 1]); } + public int getInteger(int index, int def) throws NumberFormatException { + return index + 1 < args.length ? Integer.parseInt(args[index + 1]) : def; + } + public double getDouble(int index) throws NumberFormatException { return Double.parseDouble(args[index + 1]); } + public double getDouble(int index, double def) throws NumberFormatException { + return index + 1 < args.length ? Double.parseDouble(args[index + 1]) : def; + } + public String[] getSlice(int index) { String[] slice = new String[args.length - index]; System.arraycopy(args, index, slice, 0, args.length - index); diff --git a/src/com/sk89q/worldedit/commands/UtilityCommands.java b/src/com/sk89q/worldedit/commands/UtilityCommands.java index 02637c583..7626b3882 100644 --- a/src/com/sk89q/worldedit/commands/UtilityCommands.java +++ b/src/com/sk89q/worldedit/commands/UtilityCommands.java @@ -204,7 +204,7 @@ public class UtilityCommands { throws WorldEditException { BaseBlock block = we.getBlock(player, args.getString(0), true); - int size = Math.max(1, args.getInteger(1)); + int size = Math.max(1, args.getInteger(1, 50)); we.checkMaxRadius(size); int affected = editSession.removeNear(