Skip to content

Commit 20c0b0e

Browse files
committed
Fix InvalidCommandException being thrown with incorrect arguments
1 parent b58bc8f commit 20c0b0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

common/src/main/java/revxrsal/commands/core/BaseCommandDispatcher.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public Object eval(@NotNull CommandActor actor, @NotNull ArgumentStack arguments
5252
} else if (i == arguments.size() - 1 && defaultAction == null) {
5353
throw new NoSubcommandSpecifiedException(cat);
5454
}
55-
}
56-
if (i == arguments.size() - 1 && lastCategory != null && lastCategory.defaultAction != null) {
55+
// once the category is invalid and no such command is found then stop searching
56+
} else break;
57+
if (i == arguments.size() - 1 && lastCategory.defaultAction != null) {
5758
arguments.subList(0, i).clear();
5859
return execute(lastCategory.defaultAction, actor, arguments);
5960
}
@@ -65,6 +66,7 @@ public Object eval(@NotNull CommandActor actor, @NotNull ArgumentStack arguments
6566
} else
6667
throw new InvalidSubcommandException(path, path.getLast());
6768
} else {
69+
System.out.println("Last category: " + arguments);
6870
if (lastArgument != null)
6971
throw new InvalidCommandException(path, lastArgument);
7072
}

0 commit comments

Comments
 (0)