-
-
Notifications
You must be signed in to change notification settings - Fork 20
Inspecting commands
sk89q edited this page Aug 19, 2014
·
1 revision
It is possible to inspect a dispatcher and get the commands that have been registered on it.
To get a list of commands, getCommands()
will return a set of CommandMapping
instances, which provide complete information about all registered commands.
Set<CommandMapping> mappings = dispatcher.getCommands();
for (CommandMapping mapping : mappings) {
String commandName = mapping.getPrimaryAlias();
String[] allAliases = mapping.getAllAliases();
CommandCallable callable = mapping.getCallable();
Description desc = mapping.getDescription();
String descText = desc.getShortDescription();
}
This can be used to create a help feature.
Use get(String alias)
to get a command by any of it aliases.
In addition, contains(String alias)
will check if a dispatcher contains a command.