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.
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.
SmartCommandsManager scManager = api.getSmartCommandsManager();
Retrieve the command in which you want to register your completions.
SmartCommand command = scManager.getSmartCommand("warp");
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.
Parameter
Type
Description
key
String
The argument to tab complete
completions
List<String>
The list of completions to send
Example
List<String> warps = Arrays.asList("nether", "end", "rules", "mining");
command.registerCompletions("<warp>", warps);

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]
, ...
Last updated