brigadier: add @since tags
This commit is contained in:
parent
65bb4d7a5d
commit
ddf16373fb
3 changed files with 19 additions and 3 deletions
|
|
@ -48,6 +48,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
|
||||||
*
|
*
|
||||||
* @param constant the argument type
|
* @param constant the argument type
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
BrigadierMappingBuilder<K, S> toConstant(ArgumentType<?> constant);
|
BrigadierMappingBuilder<K, S> toConstant(ArgumentType<?> constant);
|
||||||
|
|
||||||
|
|
@ -56,6 +57,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
|
||||||
*
|
*
|
||||||
* @param mapper the mapper
|
* @param mapper the mapper
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
BrigadierMappingBuilder<K, S> to(Function<K, ? extends ArgumentType<?>> mapper);
|
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>
|
* <p>This is the default option if a mapped type is specified.</p>
|
||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
BrigadierMappingBuilder<K, S> nativeSuggestions();
|
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>
|
* <p>Any previously set suggestion provider suppliers will not be used.</p>
|
||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
BrigadierMappingBuilder<K, S> cloudSuggestions();
|
BrigadierMappingBuilder<K, S> cloudSuggestions();
|
||||||
|
|
||||||
|
|
@ -84,6 +88,7 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
|
||||||
*
|
*
|
||||||
* @param provider the suggestions provider
|
* @param provider the suggestions provider
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
default BrigadierMappingBuilder<K, S> suggestedByConstant(final SuggestionProvider<S> provider) {
|
default BrigadierMappingBuilder<K, S> suggestedByConstant(final SuggestionProvider<S> provider) {
|
||||||
requireNonNull(provider, "provider");
|
requireNonNull(provider, "provider");
|
||||||
|
|
@ -95,17 +100,20 @@ public interface BrigadierMappingBuilder<K extends ArgumentParser<?, ?>, S> {
|
||||||
*
|
*
|
||||||
* @param provider the suggestions provider
|
* @param provider the suggestions provider
|
||||||
* @return this builder
|
* @return this builder
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
BrigadierMappingBuilder<K, S> suggestedBy(SuggestionProviderSupplier<K, S> provider);
|
BrigadierMappingBuilder<K, S> suggestedBy(SuggestionProviderSupplier<K, S> provider);
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface SuggestionProviderSupplier<K extends ArgumentParser<?, ?>, S> {
|
interface SuggestionProviderSupplier<K extends ArgumentParser<?, ?>, S> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new suggestion provider based on the provided argument.
|
* Create a new suggestion provider based on the provided argument.
|
||||||
*
|
*
|
||||||
* @param argument Argument to create a specialized provider for
|
* @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
|
* @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
|
* @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);
|
@Nullable SuggestionProvider<? super S> provide(@NonNull K argument, SuggestionProvider<S> useCloud);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ import static java.util.Objects.requireNonNull;
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T> {
|
public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T> {
|
||||||
|
|
||||||
public static final String COMMAND_CONTEXT_BRIGADIER_NATIVE_SENDER = "_cloud_brigadier_native_sender";
|
public static final String COMMAND_CONTEXT_BRIGADIER_NATIVE_SENDER = "_cloud_brigadier_native_sender";
|
||||||
|
|
||||||
private final ArgumentType<T> nativeType;
|
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.
|
* Create an argument parser based on a brigadier command.
|
||||||
*
|
*
|
||||||
* @param nativeType the native command type
|
* @param nativeType the native command type
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public WrappedBrigadierParser(final ArgumentType<T> nativeType) {
|
public WrappedBrigadierParser(final ArgumentType<T> nativeType) {
|
||||||
this(nativeType, DEFAULT_ARGUMENT_COUNT);
|
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.
|
* 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
|
* @param expectedArgumentCount the number of arguments the brigadier type is expected to consume
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public WrappedBrigadierParser(
|
public WrappedBrigadierParser(
|
||||||
final ArgumentType<T> nativeType,
|
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.
|
* Get the backing Brigadier {@link ArgumentType} for this parser.
|
||||||
*
|
*
|
||||||
* @return the argument type
|
* @return the argument type
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public ArgumentType<T> getNativeArgument() {
|
public ArgumentType<T> getNativeArgument() {
|
||||||
return this.nativeType;
|
return this.nativeType;
|
||||||
|
|
@ -140,8 +144,10 @@ public final class WrappedBrigadierParser<C, T> implements ArgumentParser<C, T>
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
final CompletableFuture<Suggestions> result = this.nativeType.listSuggestions(reverseMappedContext,
|
final CompletableFuture<Suggestions> result = this.nativeType.listSuggestions(
|
||||||
new SuggestionsBuilder(input, 0));
|
reverseMappedContext,
|
||||||
|
new SuggestionsBuilder(input, 0)
|
||||||
|
);
|
||||||
|
|
||||||
/* again, avert your eyes */
|
/* again, avert your eyes */
|
||||||
final List<Suggestion> suggestions = result.join().getList();
|
final List<Suggestion> suggestions = result.join().getList();
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,7 @@
|
||||||
/**
|
/**
|
||||||
* Support for wrapping brigadier {@link com.mojang.brigadier.arguments.ArgumentType ArgumentTypes}
|
* Support for wrapping brigadier {@link com.mojang.brigadier.arguments.ArgumentType ArgumentTypes}
|
||||||
* as Cloud {@link cloud.commandframework.arguments.parser.ArgumentParser}.
|
* as Cloud {@link cloud.commandframework.arguments.parser.ArgumentParser}.
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
package cloud.commandframework.brigadier.argument;
|
package cloud.commandframework.brigadier.argument;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue