Enum Argument
The EnumArgument
is an extension of ListArgument
, using a StringArgument
as a base, that adds a list of suggestions based on the Enum
provided.
Java
new StellarCommand("enum")
.addEnumArgument("material", Material.class)
.addExecution(Player.class, context -> {
Material material = context.getArgument("material");
context.getSender().sendMessage(material.name());
})
.register();
Parameters
Here is a list of all parameters:
name
- The name of the argument.enum
- AKClass
of theEnum
used.converter
- A function providing aCommandSender
and anEnum
instance from theenum
parameter, returning theSuggestion
sent to the player.- If the
Suggestion
is null, then it will be filtered out (default: uses thename
property. - This is useful when you wish to get the argument input and process the information yourself.
parse
- A function providing aCommandSender
and the argument input, returning the parsedEnum
(default:enum.valueOf(input.uppercase())
).async
- Whether the suggestions should be gotten asynchronously (default:false
).
Enum Formatting
Additionally, the addEnumArgument
method also allows you to pass in an instance of the EnumFormatting
enum class. The EnumFormatting
enum contains a list of functions that dictate how the Enum
should be converted to its String
form. There are currently four possible values:
Lowercase
Uppercase
Capitalized
- Which alters the name into its capitalized version, where the first character is [uppercase] and the rest is [lowercase].None