Package cloud.commandframework.brigadier
Class CloudBrigadierManager<C,S>
java.lang.Object
cloud.commandframework.brigadier.CloudBrigadierManager<C,S>
- Type Parameters:
C- Command sender typeS- Brigadier sender type
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 cloud.commandframework.CommandManager<C> commandManager, @NonNull Supplier<@NonNull cloud.commandframework.context.CommandContext<C>> dummyContextProvider) Create a new cloud brigadier manager -
Method Summary
Modifier and TypeMethodDescriptionvoidbackwardsBrigadierSenderMapper(@NonNull Function<@NonNull C, @Nullable S> mapper) Set the backwards mapper from Cloud to Brigadier command senders.Get the mapper between Brigadier and Cloud command senders, if one existsvoidbrigadierSenderMapper(@NonNull Function<@NonNull S, @Nullable C> mapper) Set the mapper between the Brigadier command sender type and the Cloud command sender type@NonNull com.mojang.brigadier.tree.LiteralCommandNode<S>createLiteralCommandNode(@NonNull cloud.commandframework.CommandTree.Node<@NonNull cloud.commandframework.arguments.CommandArgument<C, ?>> cloudCommand, @NonNull com.mojang.brigadier.tree.LiteralCommandNode<S> root, @NonNull com.mojang.brigadier.suggestion.SuggestionProvider<S> suggestionProvider, @NonNull com.mojang.brigadier.Command<S> executor, @NonNull BiPredicate<@NonNull S, @NonNull cloud.commandframework.permission.CommandPermission> permissionChecker) Create a literal command from Brigadier command info, and a cloud command instance@NonNull com.mojang.brigadier.tree.LiteralCommandNode<S>createLiteralCommandNode(@NonNull String label, @NonNull cloud.commandframework.Command<C> cloudCommand, @NonNull BiPredicate<@NonNull S, @NonNull cloud.commandframework.permission.CommandPermission> permissionChecker, boolean forceRegister, @NonNull com.mojang.brigadier.Command<S> executor) Create a new literal command nodevoidregisterDefaultArgumentTypeSupplier(@NonNull Class<?> clazz, @NonNull Supplier<@Nullable com.mojang.brigadier.arguments.ArgumentType<?>> supplier) Register a default mapping to between a class and a Brigadier argument type<T,K extends cloud.commandframework.arguments.parser.ArgumentParser<C, T>, O>
voidregisterMapping(@NonNull io.leangen.geantyref.TypeToken<K> argumentType, boolean nativeSuggestions, @NonNull Function<@NonNull ? extends K, @NonNull ? extends com.mojang.brigadier.arguments.ArgumentType<O>> mapper) Deprecated.<K extends cloud.commandframework.arguments.parser.ArgumentParser<C,?>>
voidregisterMapping(@NonNull io.leangen.geantyref.TypeToken<K> parserType, Consumer<BrigadierMappingBuilder<K, S>> configurer) Register a cloud-Brigadier mapping.voidsetNativeNumberSuggestions(boolean nativeNumberSuggestions) Set whether to use Brigadier's native suggestions for number argument types.<T,K extends cloud.commandframework.arguments.parser.ArgumentParser<C, T>>
voidsetNativeSuggestions(@NonNull io.leangen.geantyref.TypeToken<K> argumentType, boolean nativeSuggestions) Set whether to use Brigadier's native suggestions for an argument type with an already registered mapper.
-
Constructor Details
-
CloudBrigadierManager
public CloudBrigadierManager(@NonNull cloud.commandframework.CommandManager<C> commandManager, @NonNull Supplier<@NonNull cloud.commandframework.context.CommandContext<C>> dummyContextProvider) Create a new cloud brigadier manager- Parameters:
commandManager- Command managerdummyContextProvider- Provider of dummy context for completions
-
-
Method Details
-
brigadierSenderMapper
Set the mapper between the Brigadier command sender type and the Cloud command sender type- Parameters:
mapper- Mapper- Since:
- 1.2.0
-
brigadierSenderMapper
Get the mapper between Brigadier and Cloud command senders, if one exists- Returns:
- Mapper
- Since:
- 1.2.0
-
backwardsBrigadierSenderMapper
Set the backwards mapper from Cloud to Brigadier command senders.This is passed to completion requests for mapped argument types.
- Parameters:
mapper- the reverse brigadier sender mapper- Since:
- 1.5.0
-
setNativeNumberSuggestions
public void setNativeNumberSuggestions(boolean nativeNumberSuggestions) Set whether to use Brigadier's native suggestions for number argument types.If Brigadier's suggestions are not used, cloud's default number suggestion provider will be used.
- Parameters:
nativeNumberSuggestions- Whether or not Brigadier suggestions should be used for numbers- Since:
- 1.2.0
-
setNativeSuggestions
public <T,K extends cloud.commandframework.arguments.parser.ArgumentParser<C, void setNativeSuggestionsT>> (@NonNull io.leangen.geantyref.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 or not Brigadier suggestions should be used- Throws:
IllegalArgumentException- when there is no mapper registered for the provided argument type- Since:
- 1.2.0
-
registerMapping
@Deprecated public <T,K extends cloud.commandframework.arguments.parser.ArgumentParser<C, void registerMappingT>, O> (@NonNull io.leangen.geantyref.TypeToken<K> argumentType, boolean nativeSuggestions, @NonNull Function<@NonNull ? extends K, @NonNull ? extends com.mojang.brigadier.arguments.ArgumentType<O>> mapper) Deprecated.for removal since 1.5.0, useregisterMapping(TypeToken, Consumer)instead.Register a cloud-Brigadier mapping- Type Parameters:
T- cloud argument value typeK- cloud argument typeO- Brigadier argument type value- Parameters:
argumentType- cloud argument parser typenativeSuggestions- Whether or not Brigadier suggestions should be usedmapper- mapper function
-
registerMapping
public <K extends cloud.commandframework.arguments.parser.ArgumentParser<C,?>> void registerMapping(@NonNull io.leangen.geantyref.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
-
registerDefaultArgumentTypeSupplier
public void registerDefaultArgumentTypeSupplier(@NonNull Class<?> clazz, @NonNull Supplier<@Nullable com.mojang.brigadier.arguments.ArgumentType<?>> supplier) Register a default mapping to between a class and a Brigadier argument type- Parameters:
clazz- Type to mapsupplier- Supplier that supplies the argument type
-
createLiteralCommandNode
public @NonNull com.mojang.brigadier.tree.LiteralCommandNode<S> createLiteralCommandNode(@NonNull String label, @NonNull cloud.commandframework.Command<C> cloudCommand, @NonNull BiPredicate<@NonNull S, @NonNull cloud.commandframework.permission.CommandPermission> permissionChecker, boolean forceRegister, @NonNull com.mojang.brigadier.Command<S> executor) Create a new literal command node- Parameters:
label- Command labelcloudCommand- Cloud command instancepermissionChecker- Permission checkerforceRegister- Whether or not to force register an executor at every nodeexecutor- Command executor- Returns:
- Literal command node
-
createLiteralCommandNode
public @NonNull com.mojang.brigadier.tree.LiteralCommandNode<S> createLiteralCommandNode(@NonNull cloud.commandframework.CommandTree.Node<@NonNull cloud.commandframework.arguments.CommandArgument<C, ?>> cloudCommand, @NonNull com.mojang.brigadier.tree.LiteralCommandNode<S> root, @NonNull com.mojang.brigadier.suggestion.SuggestionProvider<S> suggestionProvider, @NonNull com.mojang.brigadier.Command<S> executor, @NonNull BiPredicate<@NonNull S, @NonNull cloud.commandframework.permission.CommandPermission> permissionChecker) Create a literal command from Brigadier command info, and a cloud command instance- Parameters:
cloudCommand- Cloud root commandroot- Brigadier root commandsuggestionProvider- Brigadier suggestions providerexecutor- Brigadier command executorpermissionChecker- Permission checker- Returns:
- Constructed literal command node
-
registerMapping(TypeToken, Consumer)instead.