Added an optional on/off argument to the toggle pickaxe command.

This commit is contained in:
TomyLobo 2011-08-09 00:17:55 +02:00
parent cc917b424c
commit e320d34b32

View File

@ -35,21 +35,35 @@ import com.sk89q.worldedit.patterns.Pattern;
public class ToolUtilCommands { public class ToolUtilCommands {
@Command( @Command(
aliases = {"/", ","}, aliases = {"/", ","},
usage = "", usage = "[on|off]",
desc = "Toggle the super pickaxe pickaxe function", desc = "Toggle the super pickaxe pickaxe function",
min = 0, min = 0,
max = 0 max = 1
) )
@CommandPermissions({"worldedit.superpickaxe"}) @CommandPermissions({"worldedit.superpickaxe"})
public static void togglePickaxe(CommandContext args, WorldEdit we, public static void togglePickaxe(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
if (session.toggleSuperPickAxe()) { String newState = args.getString(0, null);
player.print("Super pick axe enabled."); if (session.hasSuperPickAxe()) {
} else { if ("on".equals(newState)) {
player.printError("Super pick axe already enabled.");
return;
}
session.disableSuperPickAxe();
player.print("Super pick axe disabled."); 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( @Command(