Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle all aggregates not just compound
Browse files Browse the repository at this point in the history
jpenilla committed Jan 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 453dc82 commit 22e8ba7
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@

import cloud.commandframework.CommandComponent;
import cloud.commandframework.arguments.LiteralParser;
import cloud.commandframework.arguments.compound.CompoundParser;
import cloud.commandframework.arguments.aggregate.AggregateParser;
import cloud.commandframework.internal.CommandNode;
import cloud.commandframework.permission.Permission;
import cloud.commandframework.types.tuples.Pair;
@@ -136,9 +136,8 @@ private void addChildren(final CommandTreeNode<?> node, final CommandNode<C> clo
final CommandTreeNode.Argument<? extends CommandTreeNode.Argument<?>> treeNode;
if (value.parser() instanceof LiteralParser) {
treeNode = (CommandTreeNode.Argument<? extends CommandTreeNode.Argument<?>>) CommandTreeNode.literal();
} else if (value.parser() instanceof CompoundParser) {
final CompoundParser<?, C, ?> compound = (CompoundParser<?, C, ?>) value.parser();
this.handleCompoundArgument(node, child, compound);
} else if (value.parser() instanceof AggregateParser<C, ?> aggregate) {
this.handleAggregate(node, child, aggregate);
continue;
} else {
treeNode = this.commandManager.parserMapper().mapComponent(value);
@@ -152,10 +151,10 @@ private void addChildren(final CommandTreeNode<?> node, final CommandNode<C> clo
}
}

private void handleCompoundArgument(
private void handleAggregate(
final CommandTreeNode<?> node,
final CommandNode<C> child,
final CompoundParser<?, C, ?> compound
final AggregateParser<C, ?> compound
) {
final CommandTreeNode.Argument<? extends CommandTreeNode.Argument<?>> treeNode;
final ArrayDeque<Pair<String, CommandTreeNode.Argument<? extends CommandTreeNode.Argument<?>>>> nodes = new ArrayDeque<>();

0 comments on commit 22e8ba7

Please sign in to comment.