🐛 Fix issues with the help system

This commit is contained in:
Alexander Söderberg 2020-12-18 19:35:00 +01:00 committed by Alexander Söderberg
parent 97e447739c
commit c48eb28434
2 changed files with 20 additions and 4 deletions

View file

@ -207,12 +207,16 @@ public final class CommandHelpHandler<C> {
} else {
if (index < queryFragments.length) {
/* We might still be able to match an argument */
CommandTree.Node<CommandArgument<C, ?>> potentialVariable = null;
for (final CommandTree.Node<CommandArgument<C, ?>> child : head.getChildren()) {
@SuppressWarnings("unchecked") final StaticArgument<C> childArgument = (StaticArgument<C>) child
.getValue();
if (childArgument == null) {
if (!(child.getValue() instanceof StaticArgument)) {
if (child.getValue() != null) {
potentialVariable = child;
}
continue;
}
@SuppressWarnings("unchecked") final StaticArgument<C> childArgument = (StaticArgument<C>) child
.getValue();
for (final String childAlias : childArgument.getAliases()) {
if (childAlias.equalsIgnoreCase(queryFragments[index])) {
head = child;
@ -220,6 +224,10 @@ public final class CommandHelpHandler<C> {
}
}
}
if (potentialVariable != null) {
head = potentialVariable;
continue;
}
}
final String currentDescription = this.commandManager.getCommandSyntaxFormatter().apply(traversedNodes, null);
/* Attempt to parse the longest possible description for the children */