Annotations
@Command
This annotation can only be used on the command class. It tells MF what command to register on. It also requires a string, which in this case will be the command name. For example for /command
.
@Alias
This annotation will create an alias for your commands and subcommands. This can be used for both the command class and the subcommand method. You can set one or more aliases.
@Default
This annotation can only be used in a method, and it's used to set a default command. This will be the command that is run without a subcommand.
For example, if you want many commands like /command one
and your help command to not have a subcommand like /command
, you set it as default.
@SubCommand
This annotation can only be used in a method and it's used to set a subcommand.
For example, to set the command /command one
the one is the subcommand.
@Completion
This annotation can be both used on the method or on the parameter of a method. It is used to generate a tab completion for your commands. Examples:
@CompleteFor
This annotation will give you the freedom to handle the tab completion the way you want.
To use it, make a new method on your command class that returns a List<String>
then use the annotation to point it to the sub command you want to handle for.
For completing a sub command annotated with @Default
use "default"
as the target.
Follow the example under:
@Permission
This annotation can only be used in a method and it sets the which permission node is required to run the command.
@WrongUsage
This annotation will display the correct syntax of your command when the player types in the wrong usage.
You can use raw text in it or register a custom message using the MessageHandler and use it's ID
.
If the message ID
is not registered it'll simply display the ID
to the player.
@Optional
This annotation can only be used on parameters and only on the last parameter. This will make it so the last argument is optional. If the player does not type the last argument it'll return null
.
ATENTION **- Because of returning null
primitive data types will not work, for example instead of int
use Integer
, for optional parameters only though!
@Values
This annotation will work similar to the @Completion
annotation, however it can only be used in the parameter. The difference of using Values instead of Completion is that it'll be checked and the only values allowed for that argument. For example if you set a tab completion to only have the Materials STONE
and DIAMOND
even if OAK_WOOD
is a valid Material it'll return null
as it is not part of the tab completion.
Last updated