From e320d34b32d99ca4a5a0da9c9dc5b3eedca5183c Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Tue, 9 Aug 2011 00:17:55 +0200 Subject: [PATCH] Added an optional on/off argument to the toggle pickaxe command. --- .../worldedit/commands/ToolUtilCommands.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java b/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java index 94f23d74d..7c4874d73 100644 --- a/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java @@ -35,21 +35,35 @@ import com.sk89q.worldedit.patterns.Pattern; public class ToolUtilCommands { @Command( aliases = {"/", ","}, - usage = "", + usage = "[on|off]", desc = "Toggle the super pickaxe pickaxe function", min = 0, - max = 0 + max = 1 ) @CommandPermissions({"worldedit.superpickaxe"}) public static void togglePickaxe(CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { - if (session.toggleSuperPickAxe()) { - player.print("Super pick axe enabled."); - } else { + String newState = args.getString(0, null); + if (session.hasSuperPickAxe()) { + if ("on".equals(newState)) { + player.printError("Super pick axe already enabled."); + return; + } + + session.disableSuperPickAxe(); player.print("Super pick axe disabled."); } + else { + if ("off".equals(newState)) { + player.printError("Super pick axe already disabled."); + return; + } + session.enableSuperPickAxe(); + player.print("Super pick axe enabled."); + } + } @Command(