Package co.aikar.commands
Class BaseCommand
java.lang.Object
co.aikar.commands.BaseCommand
- Direct Known Subclasses:
ForwardingCommand
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleancanExecute(CommandIssuer issuer, RegisteredCommand<?> cmd) Deprecated.voiddoHelp(CommandIssuer issuer, String... args) voidDeprecated.Unstable APIgetContextFlags(Class<?> cls) Gets the current command issuer.Gets the current command manager.Gets the root command name that the user actually typedGets the actual sub command name the user typedReturns a reference to the last used CommandOperationContext.getName()String[]Gets the actual args in string form the user typedprotected com.google.common.collect.SetMultimap<String,RegisteredCommand> booleanhasPermission(CommandIssuer issuer) booleanhasPermission(Object issuer) voidhelp(CommandIssuer issuer, String[] args) voidbooleanrequiresPermission(String permission) setContextFlags(Class<?> cls, String flags) setExceptionHandler(ExceptionHandler exceptionHandler) voidDeprecated.Unstable APIvoidshowSyntax(CommandIssuer issuer, RegisteredCommand<?> cmd) tabComplete(CommandIssuer issuer, String commandLabel, String[] args) Gets tab completed data from the given command from the user.tabComplete(CommandIssuer issuer, String commandLabel, String[] args, boolean isAsync) Gets the tab complete suggestions from a given command.
-
Constructor Details
-
BaseCommand
public BaseCommand() -
BaseCommand
Deprecated.Please switch toCommandAliasfor defining all root commands.Constructor based defining of commands will be removed in the next version bump.- Parameters:
cmd-
-
-
Method Details
-
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
Gets the root command name that the user actually typed- Returns:
- Name
-
getExecSubcommand
Gets the actual sub command name the user typed- Returns:
- Name
-
getOrigArgs
Gets the actual args in string form the user typed- Returns:
- Args
-
getCurrentCommandIssuer
Gets the current command issuer.- Returns:
- The current command issuer.
-
getCurrentCommandManager
Gets the current command manager.- Returns:
- The current command manager.
-
canExecute
Deprecated.Please use command conditions for restricting execution- Parameters:
issuer-cmd-- Returns:
-
tabComplete
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.Unstable API -
showCommandHelp
Deprecated.Unstable API -
help
-
help
-
doHelp
-
doHelp
-
showSyntax
-
hasPermission
-
hasPermission
-
getRequiredPermissions
-
requiresPermission
-
getName
-
getExceptionHandler
-
setExceptionHandler
-
getDefaultRegisteredCommand
-
setContextFlags
-
getContextFlags
-
getRegisteredCommands
-
getSubCommands
-
CommandAliasfor defining all root commands.