Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ArgumentType.parse() overload that can accept source context #151

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
majorMinor: 1.2
majorMinor: 1.3
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
public interface ArgumentType<T> {
T parse(StringReader reader) throws CommandSyntaxException;

default <S> T parse(final StringReader reader, final S source) throws CommandSyntaxException {
return parse(reader);
}

default <S> CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) {
return Suggestions.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SuggestionProvider<S> getCustomSuggestions() {
@Override
public void parse(final StringReader reader, final CommandContextBuilder<S> contextBuilder) throws CommandSyntaxException {
final int start = reader.getCursor();
final T result = type.parse(reader);
final T result = type.parse(reader, contextBuilder.getSource());
final ParsedArgument<S, T> parsed = new ParsedArgument<>(start, reader.getCursor(), result);

contextBuilder.withArgument(name, parsed);
Expand Down
Loading