From 6a7cf0d56f8e2b24b7334342d02dea77dbff23c6 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 26 Mar 2016 16:44:38 +1100 Subject: [PATCH] forgot to push this --- .../plot/commands/Chat.java | 3 ++- .../plot/commands/MainCommand.java | 22 +++++-------------- .../plot/commands/Toggle.java | 1 - .../plot/commands/Visit.java | 2 +- .../plot/commands/WE_Anywhere.java | 3 ++- .../plotsquared/general/commands/Command.java | 19 ++++++++++++++-- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java index 94087f211..381d9a8de 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java @@ -14,6 +14,7 @@ public class Chat extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String... args) { - return MainCommand.onCommand(player, "toggle", "chat"); + MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null); + return true; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 01369af4f..db18974a1 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.object.RunnableVal2; import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.EconHandler; -import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.CommandDeclaration; @@ -46,7 +45,8 @@ import java.util.Arrays; public class MainCommand extends Command { private static MainCommand instance; - private Help help; + public Help help; + public Toggle toggle; private MainCommand() { super(null, true); @@ -75,7 +75,6 @@ public class MainCommand extends Command { new Auto(); new Visit(); new Set(); - new Toggle(); new Clear(); new Delete(); new Trust(); @@ -86,7 +85,6 @@ public class MainCommand extends Command { new Undeny(); new Info(); new ListCmd(); - instance.help = new Help(instance); new Debug(); new SchematicCmd(); new PluginCmd(); @@ -120,13 +118,16 @@ public class MainCommand extends Command { new BO3(); new Middle(); new Grant(); - // set commands + // Set commands new Owner(); new Desc(); new Biome(); new Alias(); new SetHome(); new Cluster(); + // Referenced commands + instance.toggle = new Toggle(); + instance.help = new Help(instance); } return instance; } @@ -155,16 +156,6 @@ public class MainCommand extends Command { args = tmp; } } - { - try { - if (args.length == 0 || MathMan.isInteger(args[0]) || CommandCategory.valueOf(args[0].toUpperCase()) != null) { - // This will default certain syntax to the help command - // e.g. /plot, /plot 1, /plot claiming - getInstance().help.execute(player, args, null, null); - return true; - } - } catch (IllegalArgumentException e) {} - } getInstance().execute(player, args, new RunnableVal3() { @Override public void run(final Command cmd, final Runnable success, final Runnable failure) { @@ -214,7 +205,6 @@ public class MainCommand extends Command { // Clear perm caching // player.deleteMeta("perm"); // Optional command scope // - String category = null; Location loc = null; Plot plot = null; boolean tp = false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java index a8cca8817..7d0108926 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Toggle.java @@ -33,7 +33,6 @@ import com.plotsquared.general.commands.CommandDeclaration; aliases = {"attribute"}, permission = "plots.use", description = "Toggle per user settings", - usage = "/plot toggle ", requiredType = RequiredType.NONE, category = CommandCategory.SETTINGS) public class Toggle extends Command { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index d3f344ae5..04d1e6970 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -43,7 +43,7 @@ import java.util.UUID; permission = "plots.visit", description = "Visit someones plot", usage = "/plot visit [player|alias|world|id] [#]", - aliases = {"v", "tp", "teleport", "goto", "home"}, + aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.NONE, category = CommandCategory.TELEPORT) public class Visit extends SubCommand { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 10e6bdc74..6623bcb7b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -36,7 +36,8 @@ public class WE_Anywhere extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String[] arguments) { - return MainCommand.onCommand(player, "plot", "toggle", "worldedit"); + MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null); + return true; } } diff --git a/Core/src/main/java/com/plotsquared/general/commands/Command.java b/Core/src/main/java/com/plotsquared/general/commands/Command.java index 17614675d..e64367a35 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -2,6 +2,7 @@ package com.plotsquared.general.commands; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.CommandCategory; +import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotMessage; @@ -9,6 +10,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal2; import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; @@ -267,7 +269,11 @@ public abstract class Command { */ public void execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { if (args.length == 0 || args[0] == null) { - C.COMMAND_SYNTAX.send(player, getUsage()); + if (parent == null) { + MainCommand.getInstance().help.displayHelp(player, null, 0); + } else { + C.COMMAND_SYNTAX.send(player, getUsage()); + } return; } if (allCommands == null || allCommands.size() == 0) { @@ -280,12 +286,21 @@ public abstract class Command { C.COMMAND_SYNTAX.send(player, getUsage()); return; } + // Help command + try { + if (args.length == 0 || MathMan.isInteger(args[0]) || CommandCategory.valueOf(args[0].toUpperCase()) != null) { + // This will default certain syntax to the help command + // e.g. /plot, /plot 1, /plot claiming + MainCommand.getInstance().help.execute(player, args, null, null); + return; + } + } catch (IllegalArgumentException e) {} // Command recommendation MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND); { List cmds = getCommands(player); if (cmds.isEmpty()) { - MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot help"); + MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage()); return; } HashSet setargs = new HashSet<>(args.length);