Skip to content

Commit

Permalink
Fix InvalidCommandException being thrown with incorrect arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Oct 10, 2021
1 parent b58bc8f commit 20c0b0e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public Object eval(@NotNull CommandActor actor, @NotNull ArgumentStack arguments
} else if (i == arguments.size() - 1 && defaultAction == null) {
throw new NoSubcommandSpecifiedException(cat);
}
}
if (i == arguments.size() - 1 && lastCategory != null && lastCategory.defaultAction != null) {
// once the category is invalid and no such command is found then stop searching
} else break;
if (i == arguments.size() - 1 && lastCategory.defaultAction != null) {
arguments.subList(0, i).clear();
return execute(lastCategory.defaultAction, actor, arguments);
}
Expand All @@ -65,6 +66,7 @@ public Object eval(@NotNull CommandActor actor, @NotNull ArgumentStack arguments
} else
throw new InvalidSubcommandException(path, path.getLast());
} else {
System.out.println("Last category: " + arguments);
if (lastArgument != null)
throw new InvalidCommandException(path, lastArgument);
}
Expand Down

0 comments on commit 20c0b0e

Please sign in to comment.