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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canExecute
(CommandIssuer issuer, RegisteredCommand<?> cmd) Deprecated.void
doHelp
(CommandIssuer issuer, String... args) void
Deprecated.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> boolean
hasPermission
(CommandIssuer issuer) boolean
hasPermission
(Object issuer) void
help
(CommandIssuer issuer, String[] args) void
boolean
requiresPermission
(String permission) setContextFlags
(Class<?> cls, String flags) setExceptionHandler
(ExceptionHandler exceptionHandler) void
Deprecated.Unstable APIvoid
showSyntax
(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 toCommandAlias
for 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
-
CommandAlias
for defining all root commands.