brigadier: add @since tags

This commit is contained in:
jmp 2021-03-12 14:02:47 -08:00 committed by Jason
parent 65bb4d7a5d
commit ddf16373fb
3 changed files with 19 additions and 3 deletions

View file

@ -48,6 +48,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
*
* @param constant the argument type
* @return this builder
* @since 1.5.0
*/
BrigadierMappingBuilder<K, S> toConstant(ArgumentType<?> constant);
@ -56,6 +57,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
*
* @param mapper the mapper
* @return this builder
* @since 1.5.0
*/
BrigadierMappingBuilder<K, S> to(Function<K, ? extends ArgumentType<?>> mapper);
@ -65,6 +67,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
* <p>This is the default option if a mapped type is specified.</p>
*
* @return this builder
* @since 1.5.0
*/
BrigadierMappingBuilder<K, S> nativeSuggestions();
@ -76,6 +79,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
* <p>Any previously set suggestion provider suppliers will not be used.</p>
*
* @return this builder
* @since 1.5.0
*/
BrigadierMappingBuilder<K, S> cloudSuggestions();
@ -84,6 +88,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
*
* @param provider the suggestions provider
* @return this builder
* @since 1.5.0
*/
default BrigadierMappingBuilder<K, S> suggestedByConstant(final SuggestionProvider<S> provider) {
requireNonNull(provider, "provider");
@ -95,17 +100,20 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
*
* @param provider the suggestions provider
* @return this builder
* @since 1.5.0
*/
BrigadierMappingBuilder<K, S> suggestedBy(SuggestionProviderSupplier<K, S> provider);
@FunctionalInterface
interface SuggestionProviderSupplier<K extends ArgumentParser<?, ?>, S> {
/**
* Create a new suggestion provider based on the provided argument.
*
* @param argument Argument to create a specialized provider for
* @param useCloud A provider that can be returned to ask the server to use cloud suggestions
* @return A new provider, or {@code null} to use the default value for the mapped argument type
* @since 1.5.0
*/
@Nullable SuggestionProvider<? super S> provide(@NonNull K argument, SuggestionProvider<S> useCloud);

View file

@ -52,6 +52,7 @@ import static java.util.Objects.requireNonNull;
* @since 1.5.0
*/
public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T> {
public static final String COMMAND_CONTEXT_BRIGADIER_NATIVE_SENDER = "_cloud_brigadier_native_sender";
private final ArgumentType<T> nativeType;
@ -61,6 +62,7 @@ public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T>
* Create an argument parser based on a brigadier command.
*
* @param nativeType the native command type
* @since 1.5.0
*/
public WrappedBrigadierParser(final ArgumentType<T> nativeType) {
this(nativeType, DEFAULT_ARGUMENT_COUNT);
@ -69,8 +71,9 @@ public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T>
/**
* Create an argument parser based on a brigadier command.
*
* @param nativeType the native command type
* @param nativeType the native command type
* @param expectedArgumentCount the number of arguments the brigadier type is expected to consume
* @since 1.5.0
*/
public WrappedBrigadierParser(
final ArgumentType<T> nativeType,
@ -84,6 +87,7 @@ public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T>
* Get the backing Brigadier {@link ArgumentType} for this parser.
*
* @return the argument type
* @since 1.5.0
*/
public ArgumentType<T> getNativeArgument() {
return this.nativeType;
@ -140,8 +144,10 @@ public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T>
false
);
final CompletableFuture<Suggestions> result = this.nativeType.listSuggestions(reverseMappedContext,
new SuggestionsBuilder(input, 0));
final CompletableFuture<Suggestions> result = this.nativeType.listSuggestions(
reverseMappedContext,
new SuggestionsBuilder(input, 0)
);
/* again, avert your eyes */
final List<Suggestion> suggestions = result.join().getList();

View file

@ -25,5 +25,7 @@
/**
* Support for wrapping brigadier {@link com.mojang.brigadier.arguments.ArgumentType ArgumentTypes}
* as Cloud {@link cloud.commandframework.arguments.parser.ArgumentParser}.
*
* @since 1.5.0
*/
package cloud.commandframework.brigadier.argument;