Allow for multiple spaces between arguments
https://github.com/Mojang/brigadier/pull/136
This commit is contained in:
@@ -325,7 +325,9 @@ public class CommandDispatcher<S> {
|
||||
|
||||
context.withCommand(child.getCommand());
|
||||
if (reader.canRead(child.getRedirect() == null ? 2 : 1)) {
|
||||
reader.skip();
|
||||
do {
|
||||
reader.skip();
|
||||
} while (reader.canRead() && reader.peek() == ARGUMENT_SEPARATOR_CHAR);
|
||||
if (child.getRedirect() != null) {
|
||||
final CommandContextBuilder<S> childContext = new CommandContextBuilder<>(this, source, child.getRedirect(), reader.getCursor());
|
||||
final ParseResults<S> parse = parseNodes(child.getRedirect(), reader, childContext);
|
||||
|
||||
@@ -449,6 +449,15 @@ public class CommandDispatcherTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void parse_multipleSpaceSeparator() throws Exception {
|
||||
subject.register(literal("foo").then(literal("bar").executes(command)));
|
||||
|
||||
assertThat(subject.execute("foo bar", source), is(42));
|
||||
verify(command).run(any(CommandContext.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteInvalidSubcommand() {
|
||||
subject.register(literal("foo").then(
|
||||
|
||||
Reference in New Issue
Block a user