-
-
Notifications
You must be signed in to change notification settings - Fork 148
Command Help
The Command System currently works with no bugs, but it is considered an Unstable API as the API may need to change, and Unstable API's are allowed to break without bumping the version number,
We do not anticipate any large changes to this system that would break your code in significant ways though, so the risk is extremely low.
In order to use the Help API, you must call in your manager before registering any commands:
manager.enableUnstableAPI("help")
This system allows ACF to generate help documents to the command issuer. If fed input, it will search all of the command metadata and filter the command list to potential desired commands. All command input, such as names, subcommands, syntax and descriptions feed the search system.
So you are able to allow users to find their potentially desired command very quickly, and you do not need to build your own help documents.
Simply ensure every command has a @Description
annotation. If the default automatically generated syntax string is not good enough, also define @Syntax
.
If you wish to provide even more keywords for the search engine to Feed against, you mays also add @HelpSearchTags("tag1 tag2 tag3")
etc to help the command be discovered.
The simplest way to show help information is by using the @HelpCommand
annotation like so:
@HelpCommand
public void doHelp(CommandSender sender, CommandHelp help) {
sendMsg(sender, heading("Anti Grief Help"));
help.showHelp();
}
@HelpCommand
is a shortcut for @Default
if not set on something else already, @UnknownHandler
if not set already on something, and @Subcommand("help")
If you are using @Default
or @UnknownHandler
for other purposes, ensure your method with @HelpCommand
is BELOW those methods to ensure the other methods are used instead.
CommandHelp
is registered as a command context, and will consume the input of the command to feed the search system, so you should never use CommandHelp
on a real command as a context.
You may throw the ShowCommandHelp
exception, optionally pass a boolean to trigger the search mode, and optionally pass your own set of search arguments too.
Otherwise, call manager.generateCommandHelp
and use accordingly.