Skip to content

Commit

Permalink
Fix root commands in Brigadier, handle MalformedEntitySelectorException
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Oct 13, 2021
1 parent e150660 commit 7876c63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ public EntitySelectorImpl(List<Entity> entities) {
public void parse(@NotNull CommandHandler handler) {
List<LiteralArgumentBuilder<?>> nodes = new ArrayList<>();
List<CommandCategory> roots = handler.getCategories().values().stream().filter(c -> c.getPath().size() == 1).collect(Collectors.toList());
List<ExecutableCommand> rootCommands = handler.getCommands().values().stream().filter(c -> c.getPath().size() == 1).collect(Collectors.toList());
for (CommandCategory root : roots) {
nodes.add(parse(literal(root.getName()), root));
}
for (ExecutableCommand root : rootCommands) {
nodes.add(parse(literal(root.getName()), root));
}
nodes.forEach(commodore::register);
}

Expand Down Expand Up @@ -153,7 +157,6 @@ private LiteralArgumentBuilder<?> parse(LiteralArgumentBuilder<?> parent, Comman
private LiteralArgumentBuilder<?> parse(LiteralArgumentBuilder<?> parent, ExecutableCommand command) {
CommandNode<?> lastParameter = null;
for (CommandParameter parameter : command.getValueParameters().values()) {

CommandNode node = getBuilder(command, parameter, true).build();
if (lastParameter == null) {
parent.then(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ protected void invalidWorld(@NotNull CommandActor actor, @NotNull InvalidWorldEx
actor.error("Invalid world: &e" + exception.getInput());
}

protected void malformedEntitySelector(@NotNull CommandActor actor, @NotNull MalformedEntitySelectorException exception) {
actor.error("Invalid selector argument: &e'" + exception.getInput() + "'");
}

protected void handleUnknownThrowable(@NotNull CommandActor actor, @NotNull Throwable throwable) {
throwable.printStackTrace();
}
Expand Down

0 comments on commit 7876c63

Please sign in to comment.