Skip to content

Operation Argument

Must be an arithmetic operator, such as = or +=. Returns an Operation enum, and use the apply method to calculate the new value from two numbers. Example:

Java
new StellarCommand("calculate")
    .addOperationArgument("operation")
    .addFloatArgument("num_one")
    .addFloatArgument("num_two")
    .addExecution<Player>(Player.class, context -> {
        Operation operation = context.getArgument<Operation>("operation");
        float numOne = (float) context.getArgument("num_one");
        float numTwo = (float) context.getArgument("num_two");
        float result = operation.apply(numOne, numTwo);
        context.getSender().sendMessage("The final result is: $result");
    });

Operation Argument

Released under the MIT License.