command-framework icon indicating copy to clipboard operation
command-framework copied to clipboard

bug: multiple arguments as Optional

Open mluizaa00 opened this issue 4 years ago • 1 comments

The @Optional annotation can't be used in the middle of arguments

Example:

// annotation here
public void handleCommand(final Context<Player> context, @Optional final String key, final Player target) {
    // code here
}

The key doesn't work at this example. The error sent is the wrong usage message Otherwise, if the key is not null (contains a input) the command works perfectly.

mluizaa00 avatar Apr 12 '21 16:04 mluizaa00

This will be a bit tricky to patch. The desired solution would be to implement a pattern system. For now, the argument parser needs to be aware of the succeeding method params, and it has to figure out whether the provided argument can be applied for one of the next params, skipping the current one.

saiintbrisson avatar Apr 12 '21 17:04 saiintbrisson