diff --git a/core/src/main/java/co/aikar/commands/BaseCommand.java b/core/src/main/java/co/aikar/commands/BaseCommand.java index b60e437d..8ca94121 100644 --- a/core/src/main/java/co/aikar/commands/BaseCommand.java +++ b/core/src/main/java/co/aikar/commands/BaseCommand.java @@ -44,6 +44,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -59,10 +60,10 @@ import java.util.stream.Stream; /** * A Base command is defined as a command group of related commands. * A BaseCommand does not imply nor enforce that they use the same root command. - * + *
* It is up to the end user how to organize their command. you could use 1 base command per * command in your application. - * + *
* Optionally (and encouraged), you can use the base command to represent a root command, and * then each actionable command is a sub command */ @@ -94,7 +95,8 @@ public abstract class BaseCommand { /** * What method was annoated with {@link PreCommand} to execute before commands. */ - @Nullable private Method preCommandHandler; + @Nullable + private Method preCommandHandler; /** * What root command the user actually entered to access the currently executing command @@ -155,14 +157,17 @@ public abstract class BaseCommand { /** * If a parent exists to this command, and it has a Subcommand annotation, prefix all subcommands in this class with this */ - @Nullable private String parentSubcommand; + @Nullable + private String parentSubcommand; - public BaseCommand() {} + public BaseCommand() { + } /** * Constructor based defining of commands will be removed in the next version bump. - * @deprecated Please switch to {@link CommandAlias} for defining all root commands. + * * @param cmd + * @deprecated Please switch to {@link CommandAlias} for defining all root commands. */ @Deprecated public BaseCommand(@Nullable String cmd) { @@ -171,6 +176,7 @@ public abstract class BaseCommand { /** * Gets the root command name that the user actually typed + * * @return Name */ public String getExecCommandLabel() { @@ -179,6 +185,7 @@ public abstract class BaseCommand { /** * Gets the actual sub command name the user typed + * * @return Name */ public String getExecSubcommand() { @@ -187,6 +194,7 @@ public abstract class BaseCommand { /** * Gets the actual args in string form the user typed + * * @return Args */ public String[] getOrigArgs() { @@ -197,8 +205,7 @@ public abstract class BaseCommand { * This should be called whenever the command gets registered. * It sets all required fields correctly and injects dependencies. * - * @param manager - * The manager to register as this command's owner and handler. + * @param manager The manager to register as this command's owner and handler. */ void onRegister(CommandManager manager) { onRegister(manager, this.commandName); @@ -208,10 +215,8 @@ public abstract class BaseCommand { * This should be called whenever the command gets registered. * It sets all required fields correctly and injects dependencies. * - * @param manager - * The manager to register as this command's owner and handler. - * @param cmd - * The command name to use register with. + * @param manager The manager to register as this command's owner and handler. + * @param cmd The command name to use register with. */ private void onRegister(CommandManager manager, String cmd) { manager.injectDependencies(this); @@ -252,8 +257,7 @@ public abstract class BaseCommand { /** * This recursively registers all subclasses of the command as subcommands, if they are of type {@link BaseCommand}. * - * @param cmd - * The command name of this command. + * @param cmd The command name of this command. */ private void registerSubclasses(String cmd) { for (Class> clazz : this.getClass().getDeclaredClasses()) { @@ -358,9 +362,7 @@ public abstract class BaseCommand { /** * Gets the subcommand name of the method given. * - * @param method - * The method to check. - * + * @param method The method to check. * @return The name of the subcommand. It returns null if the input doesn't have {@link Subcommand} attached. */ private String getSubcommandValue(Method method) { @@ -389,10 +391,8 @@ public abstract class BaseCommand { /** * Registers the given {@link BaseCommand cmd} as a child of the {@link RootCommand} linked to the name given. * - * @param name - * Name of the parent to cmd. - * @param cmd - * The {@link BaseCommand} to add as a child to the {@link RootCommand} owned name field. + * @param name Name of the parent to cmd. + * @param cmd The {@link BaseCommand} to add as a child to the {@link RootCommand} owned name field. */ private void register(String name, BaseCommand cmd) { String nameLower = name.toLowerCase(); @@ -405,10 +405,8 @@ public abstract class BaseCommand { /** * Registers the given {@link Method} as a subcommand. * - * @param method - * The method to register as a subcommand. - * @param subCommand - * The subcommand's name(s). + * @param method The method to register as a subcommand. + * @param subCommand The subcommand's name(s). */ private void registerSubcommand(Method method, String subCommand) { subCommand = manager.getCommandReplacements().replace(subCommand.toLowerCase()); @@ -437,7 +435,7 @@ public abstract class BaseCommand { if (aliasNames != null) { for (String name : aliasNames) { - register(name, new ForwardingCommand(this, subCommandParts)); + register(name, new ForwardingCommand(this, cmd, subCommandParts)); } } } @@ -448,7 +446,7 @@ public abstract class BaseCommand { * - foo qux * - bar baz * - bar qux - * + *
* For every possible sub command combination
*
* @param subCommandParts
@@ -512,11 +510,9 @@ public abstract class BaseCommand {
/**
* Gets the registered command of the given arguments.
- * @param args
- * The arguments given by the user.
*
+ * @param args The arguments given by the user.
* @return The subcommand or null if none were found.
- *
* @see #findSubCommand(String[])
*/
RegisteredCommand> getRegisteredCommand(String[] args) {
@@ -537,16 +533,11 @@ public abstract class BaseCommand {
/**
* This is ran before any command operation has been performed.
*
- * @param issuer
- * The user who executed the command.
- * @param commandLabel
- * The label the user used to execute the command. This is not the command name, but their input.
- * When there is multiple aliases, this is which alias was used
- * @param args
- * The arguments passed to the command when executing it.
- * @param isAsync
- * Whether the command is executed off of the main thread.
- *
+ * @param issuer The user who executed the command.
+ * @param commandLabel The label the user used to execute the command. This is not the command name, but their input.
+ * When there is multiple aliases, this is which alias was used
+ * @param args The arguments passed to the command when executing it.
+ * @param isAsync Whether the command is executed off of the main thread.
* @return The context which is being registered to the {@link CommandManager}'s {@link
* CommandManager#commandOperationContext thread local stack}.
*/
@@ -582,11 +573,8 @@ public abstract class BaseCommand {
/**
* Finds a subcommand of the given arguments.
*
- * @param args
- * The arguments the user input.
- *
+ * @param args The arguments the user input.
* @return The identified subcommand.
- *
* @see #findSubCommand(String[], boolean)
*/
private CommandSearch findSubCommand(String[] args) {
@@ -596,11 +584,8 @@ public abstract class BaseCommand {
/**
* Finds a subcommand of the given arguments.
*
- * @param args
- * The arguments the user input.
- * @param completion
- * Whether or not completion of arguments should kick in. This may end up with worse than wanted results.
- *
+ * @param args The arguments the user input.
+ * @param completion Whether or not completion of arguments should kick in. This may end up with worse than wanted results.
* @return The identified subcommand.
*/
private CommandSearch findSubCommand(String[] args, boolean completion) {
@@ -655,10 +640,11 @@ public abstract class BaseCommand {
/**
* Please use command conditions for restricting execution
- * @deprecated See {@link CommandConditions}
+ *
* @param issuer
* @param cmd
* @return
+ * @deprecated See {@link CommandConditions}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@@ -669,13 +655,9 @@ public abstract class BaseCommand {
/**
* Gets tab completed data from the given command from the user.
*
- * @param issuer
- * The user who executed the tabcomplete.
- * @param commandLabel
- * The label which is being used by the user.
- * @param args
- * The arguments the user has typed so far.
- *
+ * @param issuer The user who executed the tabcomplete.
+ * @param commandLabel The label which is being used by the user.
+ * @param args The arguments the user has typed so far.
* @return All possibilities in the tab complete.
*/
public List