Tab Completion
To handle tab completions using MF you have three ways. With a method annotation, on a direct parameter annotation or using the @CompleteFor
annotation.
Examples:
Method
Parameter
On both examples, it'll complete the first argument with a list of online players and the second with numbers from 1
to 20
.
Default Completions
By default MF will register the following completions:
#players
This will complete with a list of all online players.
#empty
This will complete with nothing, will be blank.
#range
Range can be used to generate a range of numbers, example
#range:20
will be from1
to20
,#range:0-5
will be from0
to5
, doing just#range
will default to1
to10
.
#enum
This will complete with a list of the enum values you have on your parameter, works with any enum.
Registering Completion
Since only the basics are registered by default, you'll probably want to register more, to do so, it's extremely similar to registering a new parameter. Based on the parameters we registered earlier, let's register a list of world names.
The first parameter is a string with the completion ID you want, in this case #worlds
, don't forget the #
.
By registering a new completion with the same ID as an existing one, you can override it.
CompleteFor
CompleteFor would need to be on a separate method and linked to the sub command you want to tab complete for. This should mostly be used if you want to create very specific tab completions.
For example: checking if the first argument is X
if so, complete the second argument with Sounds
, if first argument is Y
complete the second argument with Materials
.
Hiding tab completion
You can also set MF to hide tab completion for players that don't have permission to use the commands using the method hideTabComplete
.
Alternatively you can just make it by default on your CommandManager
constructor on your onEnable
method.
Last updated