Package co.aikar.commands
Class BaseCommand
- java.lang.Object
-
- co.aikar.commands.BaseCommand
-
- Direct Known Subclasses:
ForwardingCommand
public abstract class BaseCommand extends Object
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
-
-
Constructor Summary
Constructors Constructor Description BaseCommand()BaseCommand(@Nullable String cmd)Deprecated.Please switch toCommandAliasfor defining all root commands.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanExecute(CommandIssuer issuer, RegisteredCommand<?> cmd)Deprecated.voiddoHelp(CommandIssuer issuer, String... args)voiddoHelp(Object issuer, String... args)CommandHelpgetCommandHelp()Deprecated.Unstable APIStringgetContextFlags(Class<?> cls)CommandIssuergetCurrentCommandIssuer()Gets the current command issuer.CommandManagergetCurrentCommandManager()Gets the current command manager.RegisteredCommandgetDefaultRegisteredCommand()ExceptionHandlergetExceptionHandler()StringgetExecCommandLabel()Gets the root command name that the user actually typedStringgetExecSubcommand()Gets the actual sub command name the user typedCommandOperationContextgetLastCommandOperationContext()Returns a reference to the last used CommandOperationContext.StringgetName()String[]getOrigArgs()Gets the actual args in string form the user typedList<RegisteredCommand>getRegisteredCommands()Set<String>getRequiredPermissions()protected com.google.common.collect.SetMultimap<String,RegisteredCommand>getSubCommands()booleanhasPermission(CommandIssuer issuer)booleanhasPermission(Object issuer)voidhelp(CommandIssuer issuer, String[] args)voidhelp(Object issuer, String[] args)booleanrequiresPermission(String permission)StringsetContextFlags(Class<?> cls, String flags)BaseCommandsetExceptionHandler(ExceptionHandler exceptionHandler)voidshowCommandHelp()Deprecated.Unstable APIvoidshowSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd)List<String>tabComplete(CommandIssuer issuer, String commandLabel, String[] args)Gets tab completed data from the given command from the user.List<String>tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync)Gets the tab complete suggestions from a given command.
-
-
-
Constructor Detail
-
BaseCommand
public BaseCommand()
-
BaseCommand
@Deprecated public BaseCommand(@Nullable @Nullable String cmd)
Deprecated.Please switch toCommandAliasfor defining all root commands.Constructor based defining of commands will be removed in the next version bump.- Parameters:
cmd-
-
-
Method Detail
-
getLastCommandOperationContext
public CommandOperationContext getLastCommandOperationContext()
Returns a reference to the last used CommandOperationContext. This method is ThreadLocal, in that it can only be used on a thread that has executed a command- Returns:
-
getExecCommandLabel
public String getExecCommandLabel()
Gets the root command name that the user actually typed- Returns:
- Name
-
getExecSubcommand
public String getExecSubcommand()
Gets the actual sub command name the user typed- Returns:
- Name
-
getOrigArgs
public String[] getOrigArgs()
Gets the actual args in string form the user typed- Returns:
- Args
-
getCurrentCommandIssuer
public CommandIssuer getCurrentCommandIssuer()
Gets the current command issuer.- Returns:
- The current command issuer.
-
getCurrentCommandManager
public CommandManager getCurrentCommandManager()
Gets the current command manager.- Returns:
- The current command manager.
-
canExecute
@Deprecated public boolean canExecute(CommandIssuer issuer, RegisteredCommand<?> cmd)
Deprecated.Please use command conditions for restricting execution- Parameters:
issuer-cmd-- Returns:
-
tabComplete
public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args)
Gets tab completed data from the given command from the user.- Parameters:
issuer- The user who executed the tabcomplete.commandLabel- The label which is being used by the user.args- The arguments the user has typed so far.- Returns:
- All possibilities in the tab complete.
-
tabComplete
public List<String> tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) throws IllegalArgumentException
Gets the tab complete suggestions from a given command. This will automatically find anything which is valid for the specified command through the command's implementation.- Parameters:
issuer- The issuer of the command.commandLabel- The command name as entered by the user instead of the ACF registered name.args- All arguments entered by the user.isAsync- Whether this is run off of the main thread.- Returns:
- The possibilities to tab complete in no particular order.
- Throws:
IllegalArgumentException
-
getCommandHelp
@Deprecated public CommandHelp getCommandHelp()
Deprecated.Unstable API
-
showCommandHelp
@Deprecated public void showCommandHelp()
Deprecated.Unstable API
-
help
public void help(CommandIssuer issuer, String[] args)
-
doHelp
public void doHelp(CommandIssuer issuer, String... args)
-
showSyntax
public void showSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd)
-
hasPermission
public boolean hasPermission(Object issuer)
-
hasPermission
public boolean hasPermission(CommandIssuer issuer)
-
getRequiredPermissions
public Set<String> getRequiredPermissions()
-
requiresPermission
public boolean requiresPermission(String permission)
-
getExceptionHandler
public ExceptionHandler getExceptionHandler()
-
setExceptionHandler
public BaseCommand setExceptionHandler(ExceptionHandler exceptionHandler)
-
getDefaultRegisteredCommand
public RegisteredCommand getDefaultRegisteredCommand()
-
setContextFlags
public String setContextFlags(Class<?> cls, String flags)
-
getContextFlags
public String getContextFlags(Class<?> cls)
-
getRegisteredCommands
public List<RegisteredCommand> getRegisteredCommands()
-
getSubCommands
protected com.google.common.collect.SetMultimap<String,RegisteredCommand> getSubCommands()
-
-