@Arg @CaseInsensitive
If you want an enum argument to be parsed in a case-insensitive manner, use the @CaseInsensitive annotation.
Example
java
@Command(name = "color")
public class ColorCommand {
@Execute
void color(@Sender Player player, @Arg @CaseInsensitive Color color) {
player.sendMessage("Resolved colors as " + color);
}
private enum Color {
RED, GREEN, BLUE
}
}Here is an example of the /color command usage:
/color <color>
Input
/color redOutput
Resolved colors as REDWithout the @CaseInsensitive
Without the @CaseInsensitive annotation, the /color command accepts only exact enum values (e.g. RED, GREEN). Any other casing will result in an error.
/color <color>
Input
/color redOutput
<Invalid usage error>
Norbert Dejlich