public class SimpleDispatcher extends Object implements Dispatcher
Dispatcher.| Constructor and Description |
|---|
SimpleDispatcher()
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
call(String arguments,
Namespace namespace,
List<String> parentCommands)
Execute the command.
|
boolean |
contains(String alias)
Returns whether the dispatcher contains a registered command for the given alias.
|
CommandMapping |
get(String alias)
Get the
CommandCallable associated with an alias. |
Set<String> |
getAliases()
Get a list of all the command aliases, which includes the primary alias.
|
Set<CommandMapping> |
getCommands()
Get a list of commands.
|
Description |
getDescription()
Get the object describing the command.
|
Set<String> |
getPrimaryAliases()
Get a list of primary aliases.
|
List<String> |
getSuggestions(String arguments,
Namespace locals)
Get a list of suggestions based on input.
|
void |
registerCommand(CommandCallable callable,
String... alias)
Register a command with this dispatcher.
|
boolean |
testPermission(Namespace locals)
Test whether the user is permitted to use the command.
|
public void registerCommand(CommandCallable callable, String... alias)
DispatcherregisterCommand in interface Dispatchercallable - the command executoralias - a list of aliases, where the first alias is the primary namepublic Set<CommandMapping> getCommands()
DispatcherThe returned collection cannot be modified.
getCommands in interface Dispatcherpublic Set<String> getAliases()
DispatcherA command may have more than one alias assigned to it. The returned collection cannot be modified.
getAliases in interface Dispatcherpublic Set<String> getPrimaryAliases()
DispatcherThe returned collection cannot be modified.
getPrimaryAliases in interface Dispatcherpublic boolean contains(String alias)
Dispatchercontains in interface Dispatcheralias - the aliaspublic CommandMapping get(String alias)
DispatcherCommandCallable associated with an alias. Returns
null if no command is named by the given alias.get in interface Dispatcheralias - the aliaspublic boolean call(String arguments, Namespace namespace, List<String> parentCommands) throws CommandException, InvocationCommandException, AuthorizationException
CommandCallableparentCommands is a list of "parent" commands, including
the current command, where each deeper command is appended to
the list of parent commands.
For example, if the command entered was /world create ocean and
the command in question was the "create" command, then:
arguments would be oceanparentCommands would be world createOn the other hand, if the command was "world," then:
arguments would be create oceanparentCommands would be worldcall in interface CommandCallablearguments - The argumentsnamespace - Additional values used for executionparentCommands - The list of parent commandsCommandException - If there is an error with the commandInvocationCommandException - If there is an error with executing the commandAuthorizationException - If there is a authorization errorpublic List<String> getSuggestions(String arguments, Namespace locals) throws CommandException
CommandCompletergetSuggestions in interface CommandCompleterarguments - the arguments entered up to this pointlocals - the localsCommandException - thrown if there was a parsing errorpublic Description getDescription()
CommandCallablegetDescription in interface CommandCallablepublic boolean testPermission(Namespace locals)
CommandCallabletestPermission in interface CommandCallablelocals - The namespaceCopyright © 2015. All Rights Reserved.