From d558503028fe04e007d32b417c23aaabcc52d7c8 Mon Sep 17 00:00:00 2001 From: mcmonkey4eva Date: Tue, 4 Nov 2014 15:04:04 -0800 Subject: [PATCH] Move some AbstractCommand functionality to the core --- .../scripts/commands/AbstractCommand.java | 102 +----------------- 1 file changed, 2 insertions(+), 100 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/AbstractCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/AbstractCommand.java index 0c796ba599..524fdbe618 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/AbstractCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/AbstractCommand.java @@ -2,43 +2,12 @@ import net.aufdemrand.denizencore.exceptions.CommandExecutionException; import net.aufdemrand.denizencore.exceptions.InvalidArgumentsException; -import net.aufdemrand.denizencore.interfaces.RegistrationableInstance; import net.aufdemrand.denizen.scripts.ScriptEntry; import net.aufdemrand.denizen.utilities.DenizenAPI; +import net.aufdemrand.denizencore.scripts.commands.BaseAbstractCommand; -public abstract class AbstractCommand implements RegistrationableInstance { - - // TODO: Sanity-check this javadoc: "optional options", etc. - /** - * Contains required options for a Command in a single class for the - * ability to add optional options in the future. - * - * See {@link #withOptions} for information on using CommandOptions with this command. - */ - public class CommandOptions { - public String USAGE_HINT; - public int REQUIRED_ARGS; - - public CommandOptions(String usageHint, int numberOfRequiredArgs) { - this.USAGE_HINT = usageHint; - this.REQUIRED_ARGS = numberOfRequiredArgs; - } - } - - private boolean braced = false; - - public void setBraced() { - braced = true; - } - - public boolean isBraced() { - return braced; - } - - protected String name; - - public CommandOptions commandOptions; +public abstract class AbstractCommand extends BaseAbstractCommand { @Override public AbstractCommand activate() { @@ -56,54 +25,6 @@ public AbstractCommand as(String commandName) { public abstract void execute(ScriptEntry scriptEntry) throws CommandExecutionException; - @Override - public String getName() { - return name; - } - - /** - * Returns the {@link CommandOptions} specified at startup. - * - * @return commandOptions - * - */ - public CommandOptions getOptions() { - return commandOptions; - } - - /** - * Returns USAGE_HINT specified in the {@link CommandOptions}, if specified. - * - * @return USAGE_HINT if specified, otherwise "No usage defined! See documentation for more information!" - * - */ - public String getUsageHint() { - return !commandOptions.USAGE_HINT.equals("") ? commandOptions.USAGE_HINT : "No usage defined! See documentation for more information!"; - } - - /** - * Part of the Plugin disable sequence. - * - * Can be '@Override'n by a Command which requires a method when bukkit sends a - * onDisable() to Denizen. (ie. Server shuts down or restarts) - * - */ - public void onDisable() { - - } - - /** - * Part of the Plugin enable sequence. This is called when the command is - * instanced by the CommandRegistry, which is generally on a server startup. - * - * Can be '@Override'n by a Command which requires a method when starting, such - * as registering as a Bukkit Listener. - * - */ - public void onEnable() { - - } - /** * Called by the CommandExecuter before the execute() method is called. Arguments * should be iterated through and checked before continuing to execute(). Note that @@ -124,23 +45,4 @@ public void onEnable() { */ public abstract void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException; - /** - * Creates a new {@link CommandOptions} for this command. - * - * @param usageHint - * A String representation of the suggested usage format of this command. - * Typically []'s represent required arguments and ()'s represent optional arguments. - * Example from SWITCH command: [LOCATION:x,y,z,world] (STATE:ON|OFF|TOGGLE) (DURATION:#) - * @param numberOfRequiredArgs - * The minimum number of required arguments needed to ensure proper functionality. The - * Executer will not parseArgs() for this command if this number is not met. - * @return - * The newly created CommandOptions object for the possibility of setting other - * criteria, though currently none exists. - * - */ - public CommandOptions withOptions(String usageHint, int numberOfRequiredArgs) { - this.commandOptions = new CommandOptions(usageHint, numberOfRequiredArgs); - return commandOptions; - } }