fix child command issues

This commit is contained in:
dfsek
2021-03-08 00:37:25 -07:00
parent a5d101ff61
commit 0cd5898107
2 changed files with 3 additions and 1 deletions

View File

@@ -50,8 +50,9 @@ public class TerraCommandManager implements CommandManager {
boolean req = true;
for(Argument argument : command.arguments()) {
if(!req && argument.required())
if(!req && argument.required()) {
throw new MalformedCommandException("Required arguments must come first! Arguments: " + Arrays.toString(command.arguments()));
}
req = argument.required();
if(args.isEmpty()) {

View File

@@ -28,6 +28,7 @@ public class CommandTest {
manager.execute("test", Arrays.asList("s2", "first", "2"));
manager.execute("test", Arrays.asList("sub1", "first", "2", "3.4"));
manager.execute("test", Arrays.asList("sub2", "first", "2"));
manager.execute("test", Arrays.asList("first", "2")); // Parent command args
}
@Test