New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected argument collision in single-argument branches #39
Comments
It appears that one of the |
Yes, changing the sorting would be the easy fix and was my first thought as well (Not nodes without children, though, but nodes that have an command assigned) However, I still think it would be a bit neater if the parser already threw an exception when the reader reached the end and the parsed command is not executable. There are two reasons why I'd prefer that soution |
There are 2 dispatcher.register(literal("goal")
.then(argument("y", integer())
.executes(c -> {
setGoal(new GoalYLevel(
c.getArgument("y", Integer.class)
));
return 0;
})
.then(argument("x", integer())
.then(argument("z", integer())
.executes(c -> {
setGoal(new GoalXZ(
c.getArgument("x", Integer.class),
c.getArgument("z", Integer.class)
));
return 0;
})
)
.then(argument("y", integer())
.then(argument("z", integer())
.executes(c -> {
setGoal(new GoalBlock(
c.getArgument("x", Integer.class),
c.getArgument("y", Integer.class),
c.getArgument("z", Integer.class)
));
return 0;
})
)
)
)
); |
Consider the following command tree:
This should have 3 possible usages
However, when I try to execute the command with a single integer argument (via
goal 1
) an exception is thrown!Both the 2-arg and 3-arg usages work as intended:
I have found that the only solution to this is to rename the argument in the single argument branch from
y
.I believe this issue relates to the comment made by Dinnerbone Here.
The text was updated successfully, but these errors were encountered: