Skip to content

Hey there! If you like my work, you can support me by sponsoring me on GitHub. Thanks! ❤

Sponsor me
on GitHub

@Priority

The @Priority annotation lets you control the order of executor matching when multiple executors accept the same input.

For example

To prioritize an executor with int over one with String, use @Priority(PriorityValue.HIGH):

java
@Command(name = "hello")
public class HelloCommand {
    @Execute
    void execute(@Arg String text) {
        print("Matches String executor!! " + text);
    }

    @Execute
    @Priority(PriorityValue.HIGH)
    void execute(@Arg int number) {
        print("Matches int executor! " + number);
    }
}

All values of the PriorityValue

Now there’s no risk that the input /hello 10 will trigger the executor with the String argument.

/hello <text/number>
Input
/hello 10
Output
Matches int executor! 10
/hello <text/number>
Input
/hello hi
Output
Matches String executor! hi

WARNING - The order in the file does not matter!

Java discards method order during compilation.

Made by LiteDevelopers and Contributors with ❤️