Automatic tab completor
This is a guide to learn how to create and how to use the automatic tab completor.
Automatic tab completer
What is it ?
By creating an advanced command aid system for your command, you also created the automatic tab completer. Indeed, this tab completer is based on the keys in the JSON file.
However, to only use the automatic tab completer, the property component
is optional but type
is always mandatory. You can also add a specific permission to tab complete command arguments by using the permission
property.
If you're using a permission, completions will be sent only if the user has this permission.
The value of the property tabComplete
must be set to true
in the commands.json
file to use the automatic tab completer.
Non permanents arguments
The automatic tab completer also considers non permanents arguments. These arguments can be of two types:
Those which are part of a list like names of warps or names of online players.
Those which must be written by a user like the name of an item or a line of its lore.
Arguments which are part of a list
If an argument is a part of a list of other arguments, it must be defined between <
and >
symbols.
Examples: <player>
, <warp>
, <faction>
, ...
Register completions
With SmartCommands
, you can register a list of arguments which will be sent automatically. First, when you register you command, retrieve the SmartCommandsManager
class from the SmartCommandsAPI
class.
Retrieve the command in which you want to register your completions.
Now, we're ready to register our completions. We will use the registerCompletions() method from the SmartCommand class. First, let's see this method in more details.
You can also get the completions and unregister an argument if you want by using the getCompletion(String key)
and the unregisterCompletions(String key)
methods.
The argument <player>
is automatically replaced by the list of names of online players so you do not have to register it.
Example
Arguments which must be written by a user
If an argument must be written by a user, it must be defined in square brackets.
Examples: [name]
, [line]
, ...
This type of argument cannot be tab completed so completion will not be sent to users.
Last updated