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,
CommandLocals locals,
String[] parentCommands)
Execute the correct command based on the input.
|
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.
|
SimpleDescription |
getDescription()
Get an object describing this command.
|
Set<String> |
getPrimaryAliases()
Get a list of primary aliases.
|
List<String> |
getSuggestions(String arguments,
CommandLocals locals)
Get a list of suggestions based on input.
|
void |
registerCommand(CommandCallable callable,
String... alias)
Register a command with this dispatcher.
|
boolean |
testPermission(CommandLocals locals)
Test whether this command can be executed with the given context.
|
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, CommandLocals locals, String[] parentCommands) throws CommandException
CommandCallableThe implementing class must perform the necessary permission checks.
call in interface CommandCallablearguments - the argumentslocals - the localsparentCommands - a list of parent commands, with the first most entry being the top-level commandCommandException - thrown on a command errorpublic List<String> getSuggestions(String arguments, CommandLocals locals) throws CommandException
CommandCompletergetSuggestions in interface CommandCompleterarguments - the arguments entered up to this pointlocals - the localsCommandException - thrown if there was a parsing errorpublic SimpleDescription getDescription()
CommandCallablegetDescription in interface CommandCallablepublic boolean testPermission(CommandLocals locals)
CommandCallabletestPermission in interface CommandCallablelocals - the localsCopyright © 2010-2014. All Rights Reserved.