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
public final class CloudBrigadierManager<C,S> extends java.lang.Object
Manager used to map cloudCommand
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
Constructors Constructor Description CloudBrigadierManager(@NonNull cloud.commandframework.CommandManager<C> commandManager, @NonNull java.util.function.Supplier<@NonNull cloud.commandframework.context.CommandContext<C>> dummyContextProvider)
Create a new cloud brigadier manager
-
Method Summary
Modifier and Type Method Description @Nullable java.util.function.Function<@NonNull S,@Nullable C>
brigadierSenderMapper()
Get the mapper between Brigadier and Cloud command senders, if one existsvoid
brigadierSenderMapper(@NonNull java.util.function.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 java.util.function.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 java.lang.String label, @NonNull cloud.commandframework.Command<C> cloudCommand, @NonNull java.util.function.BiPredicate<@NonNull S,@NonNull cloud.commandframework.permission.CommandPermission> permissionChecker, boolean forceRegister, @NonNull com.mojang.brigadier.Command<S> executor)
Create a new literal command nodevoid
registerDefaultArgumentTypeSupplier(@NonNull java.lang.Class<?> clazz, @NonNull java.util.function.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 java.util.function.Function<? extends K,? extends com.mojang.brigadier.arguments.ArgumentType<O>> mapper)
Register a cloud-Brigadier mappingvoid
setNativeNumberSuggestions(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 Detail
-
CloudBrigadierManager
public CloudBrigadierManager(@NonNull cloud.commandframework.CommandManager<C> commandManager, @NonNull java.util.function.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 Detail
-
brigadierSenderMapper
public void brigadierSenderMapper(@NonNull java.util.function.Function<@NonNull S,@Nullable C> mapper)
Set the mapper between the Brigadier command sender type and the Cloud command sender type- Parameters:
mapper
- Mapper- Since:
- 1.2.0
-
brigadierSenderMapper
public @Nullable java.util.function.Function<@NonNull S,@Nullable C> brigadierSenderMapper()
Get the mapper between Brigadier and Cloud command senders, if one exists- Returns:
- Mapper
- Since:
- 1.2.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,T>> void setNativeSuggestions(@NonNull io.leangen.geantyref.TypeToken<K> argumentType, boolean nativeSuggestions) throws java.lang.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:
java.lang.IllegalArgumentException
- when there is no mapper registered for the provided argument type- Since:
- 1.2.0
-
registerMapping
public <T,K extends cloud.commandframework.arguments.parser.ArgumentParser<C,T>,O> void registerMapping(@NonNull io.leangen.geantyref.TypeToken<K> argumentType, boolean nativeSuggestions, @NonNull java.util.function.Function<? extends K,? extends com.mojang.brigadier.arguments.ArgumentType<O>> mapper)
Register a cloud-Brigadier mapping- Type Parameters:
T
- cloud argument value typeK
- cloud argument typeO
- Brigadier argument type value- Parameters:
argumentType
- cloud argument typenativeSuggestions
- Whether or not Brigadier suggestions should be usedmapper
- mapper function
-
registerDefaultArgumentTypeSupplier
public void registerDefaultArgumentTypeSupplier(@NonNull java.lang.Class<?> clazz, @NonNull java.util.function.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 java.lang.String label, @NonNull cloud.commandframework.Command<C> cloudCommand, @NonNull java.util.function.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 java.util.function.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
-
-