diff --git a/bluecommands-core/src/main/java/de/bluecolored/bluecommands/Command.java b/bluecommands-core/src/main/java/de/bluecolored/bluecommands/Command.java index 24f8f61..4134849 100644 --- a/bluecommands-core/src/main/java/de/bluecolored/bluecommands/Command.java +++ b/bluecommands-core/src/main/java/de/bluecolored/bluecommands/Command.java @@ -86,7 +86,7 @@ void parse(ParseData data) { } } } else if (!subCommands.isEmpty()) { - if (isTreeOptional()) { + if (isSubTreeOptional()) { gatherAllExecutables(data.getContext(), executable -> { data.getResult().addMatch(new ParseMatch<>(executable, data.getContext(), data.getArguments(), data.getCommandStack())); }); @@ -108,6 +108,12 @@ private void gatherAllExecutables(C context, Consumer> c subCommand.gatherAllExecutables(context, consumer); } + private boolean isSubTreeOptional() { + for (Command subCommand : subCommands) + if (!subCommand.isTreeOptional()) return false; + return true; + } + private boolean isTreeOptional() { long now = System.currentTimeMillis(); if (lastTreeOptionalTime < now - 1000) {