mirror of
https://github.com/aikar/commands.git
synced 2026-06-11 18:40:37 +00:00
Support context on @Default! Hooray!!!!
@Subcommand("list") @Default
public void onFoo(CommandSender sender, @Default("1") Integer page) {}
type stuff will now work with /cmd list 2 and /cmd 2
This commit is contained in:
@@ -309,16 +309,18 @@ public abstract class BaseCommand {
|
||||
try {
|
||||
CommandOperationContext commandContext = preCommandOperation(issuer, commandLabel, args);
|
||||
|
||||
if (args.length == 0) {
|
||||
executeSubcommand(commandContext, DEFAULT, issuer);
|
||||
return;
|
||||
if (args.length > 0) {
|
||||
CommandSearch cmd = findSubCommand(args);
|
||||
if (cmd != null) {
|
||||
execSubcommand = cmd.getCheckSub();
|
||||
final String[] execargs = Arrays.copyOfRange(args, cmd.argIndex, args.length);
|
||||
executeCommand(commandContext, issuer, execargs, cmd.cmd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CommandSearch cmd = findSubCommand(args);
|
||||
if (cmd != null) {
|
||||
execSubcommand = cmd.getCheckSub();
|
||||
final String[] execargs = Arrays.copyOfRange(args, cmd.argIndex, args.length);
|
||||
executeCommand(commandContext, issuer, execargs, cmd.cmd);
|
||||
if (subCommands.get(DEFAULT) != null) {
|
||||
executeSubcommand(commandContext, DEFAULT, issuer, args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user