Improved command detection algorithm, fixed //size.

This commit is contained in:
sk89q 2011-02-21 23:15:19 -08:00
parent 35ae72e8b7
commit ce544da46d
2 changed files with 55 additions and 53 deletions

View File

@ -853,21 +853,26 @@ public class WorldEdit {
} }
String searchCmd = split[0].toLowerCase(); String searchCmd = split[0].toLowerCase();
if (commands.hasCommand(searchCmd)
|| (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) // Try to detect the command
|| (searchCmd.length() >= 2 && searchCmd.charAt(0) == '/' if (commands.hasCommand(searchCmd)) {
&& commands.hasCommand(searchCmd.substring(1)))) { } else if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) {
if (config.noDoubleSlash && commands.hasCommand("/" + searchCmd)) {
split[0] = "/" + split[0]; split[0] = "/" + split[0];
} else if (commands.hasCommand(searchCmd.substring(1))) { } else if (commands.hasCommand(searchCmd.substring(1))) {
split[0] = split[0].substring(1); split[0] = split[0].substring(1);
} }
// No command found!
if (!commands.hasCommand(split[0])) {
return false;
}
LocalSession session = getSession(player); LocalSession session = getSession(player);
BlockBag blockBag = session.getBlockBag(player); BlockBag blockBag = session.getBlockBag(player);
session.tellVersion(player); session.tellVersion(player);
// Create an edit session
EditSession editSession = EditSession editSession =
new EditSession(player.getWorld(), new EditSession(player.getWorld(),
session.getBlockChangeLimit(), blockBag); session.getBlockChangeLimit(), blockBag);
@ -905,9 +910,6 @@ public class WorldEdit {
flushBlockBag(player, editSession); flushBlockBag(player, editSession);
} }
}
return false;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.printError("Number expected; string given."); player.printError("Number expected; string given.");
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {

View File

@ -425,7 +425,7 @@ public class SelectionCommands {
} }
@Command( @Command(
aliases = {"/m", "//size"}, aliases = {"/size"},
usage = "", usage = "",
desc = "Get information about the selection", desc = "Get information about the selection",
min = 0, min = 0,