use of com.mojang.brigadier.context.ParsedArgument in project SpongeCommon by SpongePowered.
the class SpongeArgumentCommandNode method parse.
@Override
public final void parse(final StringReader reader, final CommandContextBuilder<CommandSourceStack> contextBuilder) throws CommandSyntaxException {
final int start = reader.getCursor();
final SpongeCommandContextBuilder builder = (SpongeCommandContextBuilder) contextBuilder;
final T result = this.parser.parse(this.key, builder, (SpongeStringReader) reader, this.modifier);
if (result != null) {
builder.putEntry(this.key, result);
final ParsedArgument<CommandSourceStack, T> parsed = new ParsedArgument<>(start, reader.getCursor(), result);
builder.withArgumentInternal(this.getName(), parsed, false);
builder.withNode(this, parsed.getRange());
} else if (this.parser.doesNotRead()) {
// Assume this is a null "optional" parser and add the node as read so that we dont end up with an empty context
builder.withNode(this, StringRange.at(start));
}
}
Aggregations