diff --git a/shared/src/main/java/net/codersky/mcutils/cmd/SubCommandHandler.java b/shared/src/main/java/net/codersky/mcutils/cmd/SubCommandHandler.java index 612ceee..343d0cc 100644 --- a/shared/src/main/java/net/codersky/mcutils/cmd/SubCommandHandler.java +++ b/shared/src/main/java/net/codersky/mcutils/cmd/SubCommandHandler.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -38,7 +39,18 @@ public boolean onCommand(@NotNull MCCommand
mainCmd, @NotNull S sender, @N
}
public List mainCommand, @NotNull S sender, @NotNull String[] args) {
- return onUsedCommand(mainCommand, sender, args, (cmd, newArgs) -> cmd.onTab(sender, newArgs), List.of(), false);
+ return onUsedCommand(mainCommand, sender, args, (cmd, newArgs) -> {
+ if (subCommands.isEmpty() || args.length > 1)
+ return cmd.onTab(sender, newArgs);
+ final List subCmd : subCommands) {
+ tabs.add(subCmd.getName());
+ tabs.addAll(subCmd.getAliases());
+ }
+ return tabs;
+ }, List.of(), false);
}
@SafeVarargs