update brig in the API and patch cleanup
This commit is contained in:
@ -39,7 +39,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
|
||||
// Paper end - configure mockito agent that is needed in newer java versions
|
||||
|
||||
dependencies {
|
||||
api("com.mojang:brigadier:1.2.9") // Paper - Brigadier command api
|
||||
api("com.mojang:brigadier:1.3.10") // Paper - Brigadier command api
|
||||
// api dependencies are listed transitively to API consumers
|
||||
api("com.google.guava:guava:33.3.1-jre")
|
||||
api("com.google.code.gson:gson:2.11.0")
|
||||
|
||||
@ -37,10 +37,31 @@ public interface CustomArgumentType<T, N> extends ArgumentType<T> {
|
||||
* @param reader string reader input
|
||||
* @return parsed value
|
||||
* @throws CommandSyntaxException if an error occurs while parsing
|
||||
* @see #parse(StringReader, Object)
|
||||
*/
|
||||
@Override
|
||||
T parse(final StringReader reader) throws CommandSyntaxException;
|
||||
|
||||
/**
|
||||
* Parses the argument into the custom type ({@code T}). Keep in mind
|
||||
* that this parsing will be done on the server. This means that if
|
||||
* you throw a {@link CommandSyntaxException} during parsing, this
|
||||
* will only show up to the user after the user has executed the command
|
||||
* not while they are still entering it.
|
||||
* <p>
|
||||
* This method provides the command source for additional context when parsing. You
|
||||
* may have to do your own {@code instanceof} checks for {@link io.papermc.paper.command.brigadier.CommandSourceStack}.
|
||||
*
|
||||
* @param reader string reader input
|
||||
* @param source source of the command
|
||||
* @return parsed value
|
||||
* @throws CommandSyntaxException if an error occurs while parsing
|
||||
*/
|
||||
@Override
|
||||
default <S> T parse(final StringReader reader, final S source) throws CommandSyntaxException {
|
||||
return ArgumentType.super.parse(reader, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the native type that this argument uses,
|
||||
* the type that is sent to the client.
|
||||
@ -95,13 +116,35 @@ public interface CustomArgumentType<T, N> extends ArgumentType<T> {
|
||||
return this.convert(this.getNativeType().parse(reader));
|
||||
}
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
@Override
|
||||
default <S> T parse(final StringReader reader, final S source) throws CommandSyntaxException {
|
||||
return this.convert(this.getNativeType().parse(reader, source), source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the value from the native type to the custom argument type.
|
||||
*
|
||||
* @param nativeType native argument provided value
|
||||
* @return converted value
|
||||
* @throws CommandSyntaxException if an exception occurs while parsing
|
||||
* @see #convert(Object, Object)
|
||||
*/
|
||||
T convert(N nativeType) throws CommandSyntaxException;
|
||||
|
||||
/**
|
||||
* Converts the value from the native type to the custom argument type.
|
||||
* <p>
|
||||
* This method provides the command source for additional context when converting. You
|
||||
* may have to do your own {@code instanceof} checks for {@link io.papermc.paper.command.brigadier.CommandSourceStack}.
|
||||
*
|
||||
* @param nativeType native argument provided value
|
||||
* @param source source of the command
|
||||
* @return converted value
|
||||
* @throws CommandSyntaxException if an exception occurs while parsing
|
||||
*/
|
||||
default <S> T convert(final N nativeType, final S source) throws CommandSyntaxException {
|
||||
return this.convert(nativeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user