Package org.incendo.cloud.brigadier
Class CloudBrigadierManager<C,S>
java.lang.Object
org.incendo.cloud.brigadier.CloudBrigadierManager<C,S>
- Type Parameters:
C- cloud command sender typeS- brigadier command source type
- All Implemented Interfaces:
SenderMapperHolder<S,C>
Manager used to map cloud
Command
The structure of this class is largely inspired by ACFBrigadiermanager in the ACF project, which was originally written by MiniDigger and licensed under the MIT license.
-
Constructor Summary
ConstructorsConstructorDescriptionCloudBrigadierManager(@NonNull CommandManager<C> commandManager, @NonNull Supplier<@NonNull CommandContext<C>> dummyContextProvider, @NonNull SenderMapper<S, C> brigadierSourceMapper) Create a new cloud brigadier manager -
Method Summary
Modifier and TypeMethodDescriptionReturns the default argument type factories.Returns a factory that createsliteral command nodesfrom Cloud commands.mappings()Returns the mappings between Cloud and Brigadier types.<T> voidregisterDefaultArgumentTypeSupplier(@NonNull Class<T> clazz, @NonNull ArgumentTypeFactory<T> factory) Register a default mapping to between a class and a Brigadier argument type<K extends ArgumentParser<C,?>>
voidregisterMapping(@NonNull TypeToken<K> parserType, Consumer<BrigadierMappingBuilder<K, S>> configurer) Register a cloud-Brigadier mapping.voidsetNativeNumberSuggestions(boolean nativeNumberSuggestions) Sets whether Brigadier's native suggestions for number types will be used, or if cloud's number suggestions should be used instead.<T,K extends ArgumentParser<C, T>>
voidsetNativeSuggestions(@NonNull TypeToken<K> argumentType, boolean nativeSuggestions) Set whether to use Brigadier's native suggestions for an argument type with an already registered mapper.settings()Returns aConfigurableinstance that can be used to modify the settings for this instance.
-
Constructor Details
-
CloudBrigadierManager
public CloudBrigadierManager(@NonNull CommandManager<C> commandManager, @NonNull Supplier<@NonNull CommandContext<C>> dummyContextProvider, @NonNull SenderMapper<S, C> brigadierSourceMapper) Create a new cloud brigadier manager- Parameters:
commandManager- Command managerdummyContextProvider- Provider of dummy context for completionsbrigadierSourceMapper- Mapper between the Brigadier command source type and cloud command sender type
-
-
Method Details
-
settings
Returns aConfigurableinstance that can be used to modify the settings for this instance.- Returns:
- settings instance
- Since:
- 2.0.0
-
senderMapper
- Specified by:
senderMapperin interfaceSenderMapperHolder<C,S>
-
setNativeNumberSuggestions
@API(status=STABLE, since="1.2.0") public void setNativeNumberSuggestions(boolean nativeNumberSuggestions) Sets whether Brigadier's native suggestions for number types will be used, or if cloud's number suggestions should be used instead. At the time of writing the native suggestions are equivalent toSuggestionProvider.noSuggestions().The default is to use cloud's suggestions, or
false.- Parameters:
nativeNumberSuggestions- whether Brigadier suggestions should be used for number types- Since:
- 1.2.0
-
setNativeSuggestions
@API(status=STABLE, since="1.2.0") public <T,K extends ArgumentParser<C, void setNativeSuggestionsT>> (@NonNull TypeToken<K> argumentType, boolean nativeSuggestions) throws IllegalArgumentException Set whether to use Brigadier's native suggestions for an argument type with an already registered mapper.If Brigadier's suggestions are not used, suggestions will fall back to the cloud suggestion provider.
- Type Parameters:
T- argument typeK- cloud argument parser type- Parameters:
argumentType- cloud argument parser typenativeSuggestions- whether Brigadier suggestions should be used- Throws:
IllegalArgumentException- when there is no mapper registered for the provided argument type- Since:
- 1.2.0
-
registerMapping
@API(status=STABLE, since="1.5.0") public <K extends ArgumentParser<C,?>> void registerMapping(@NonNull TypeToken<K> parserType, Consumer<BrigadierMappingBuilder<K, S>> configurer) Register a cloud-Brigadier mapping.- Type Parameters:
K- cloud argument parser type- Parameters:
parserType- The cloud argument parser typeconfigurer- a callback that will configure the mapping attributes- Since:
- 1.5.0
-
mappings
Returns the mappings between Cloud and Brigadier types.- Returns:
- the mappings
- Since:
- 2.0.0
-
literalBrigadierNodeFactory
@API(status=STABLE, since="2.0.0") public @NonNull LiteralBrigadierNodeFactory<C,S> literalBrigadierNodeFactory()Returns a factory that createsliteral command nodesfrom Cloud commands.- Returns:
- the literal node factory
- Since:
- 2.0.0
-
registerDefaultArgumentTypeSupplier
@API(status=STABLE, since="2.0.0") public <T> void registerDefaultArgumentTypeSupplier(@NonNull Class<T> clazz, @NonNull ArgumentTypeFactory<T> factory) Register a default mapping to between a class and a Brigadier argument type- Type Parameters:
T- the type- Parameters:
clazz- the type to mapfactory- factory that creates the argument type- Since:
- 2.0.0
-
defaultArgumentTypeFactories
@API(status=INTERNAL, since="2.0.0") public @NonNull Map<@NonNull Class<?>,@NonNull ArgumentTypeFactory<?>> defaultArgumentTypeFactories()Returns the default argument type factories.- Returns:
- immutable view of the factories
- Since:
- 2.0.0
-