Class BukkitCommandManager<C>
- Type Parameters:
C- Command sender type
- All Implemented Interfaces:
cloud.commandframework.brigadier.BrigadierManagerHolder<C>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumReasons to explain why Brigadier failed to initializeNested classes/interfaces inherited from class cloud.commandframework.CommandManager
cloud.commandframework.CommandManager.ManagerSettings, cloud.commandframework.CommandManager.RegistrationState -
Constructor Summary
ConstructorsConstructorDescriptionBukkitCommandManager(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull Function<@NonNull cloud.commandframework.CommandTree<@NonNull C>, @NonNull cloud.commandframework.execution.CommandExecutionCoordinator<@NonNull C>> commandExecutionCoordinator, @NonNull Function<@NonNull org.bukkit.command.CommandSender, @NonNull C> commandSenderMapper, @NonNull Function<@NonNull C, @NonNull org.bukkit.command.CommandSender> backwardsCommandSenderMapper) Construct a new Bukkit command manager -
Method Summary
Modifier and TypeMethodDescription@Nullable cloud.commandframework.brigadier.CloudBrigadierManager<C,?> protected final voidCheck whether Brigadier can be used on the server instance@NonNull BukkitCommandMetaCreate default command meta datastatic @NonNull BukkitCommandManager<@NonNull org.bukkit.command.CommandSender>createNative(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull Function<@NonNull cloud.commandframework.CommandTree<@NonNull org.bukkit.command.CommandSender>, @NonNull cloud.commandframework.execution.CommandExecutionCoordinator<@NonNull org.bukkit.command.CommandSender>> commandExecutionCoordinator) Create a command manager using Bukkit'sCommandSenderas the sender type.Get the backwards command sender pluginGet the command sender mapper@NonNull org.bukkit.plugin.PluginGet the plugin that owns the managerprotected final booleanfinal booleanhasPermission(@NonNull C sender, @NonNull String permission) final @NonNull Set<@NonNull CloudBukkitCapabilities>Check for the platform capabilitiesfinal booleanqueryCapability(@NonNull CloudBukkitCapabilities capability) Deprecated.for removal since 1.7.0.voidAttempt to register the Brigadier mapper, and return it.protected final voidsetSplitAliases(boolean value) final @NonNull StringstripNamespace(@NonNull String command) Strip the plugin namespace from a plugin namespaced command.@NonNull cloud.commandframework.tasks.TaskRecipeCreate a new task recipe.Methods inherited from class cloud.commandframework.CommandManager
argumentBuilder, capabilities, captionRegistry, captionRegistry, captionVariableReplacementHandler, captionVariableReplacementHandler, command, command, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandExecutionCoordinator, commandRegistrationHandler, commandRegistrationHandler, commands, commandSuggestionProcessor, commandSuggestionProcessor, commandSyntaxFormatter, commandSyntaxFormatter, commandTree, createCommandHelpHandler, createCommandHelpHandler, deleteRootCommand, executeCommand, flagBuilder, getCaptionRegistry, getCommandHelpHandler, getCommandHelpHandler, getCommandRegistrationHandler, getCommands, getCommandSuggestionProcessor, getCommandSyntaxFormatter, getCommandTree, getExceptionHandler, getParserRegistry, getRegistrationState, getSetting, handleException, hasCapability, hasPermission, isCommandRegistrationAllowed, lockRegistration, parameterInjectorRegistry, parserRegistry, postprocessContext, preprocessContext, registerCapability, registerCommandPostProcessor, registerCommandPreProcessor, registerDefaultCaptions, registerExceptionHandler, registrationState, requireState, rootCommands, setCaptionRegistry, setCommandRegistrationHandler, setCommandSuggestionProcessor, setCommandSyntaxFormatter, setSetting, suggest, transitionIfPossible, transitionOrThrow
-
Constructor Details
-
BukkitCommandManager
public BukkitCommandManager(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull Function<@NonNull cloud.commandframework.CommandTree<@NonNull C>, @NonNull cloud.commandframework.execution.CommandExecutionCoordinator<@NonNull C>> commandExecutionCoordinator, @NonNull Function<@NonNull org.bukkit.command.CommandSender, throws Exception@NonNull C> commandSenderMapper, @NonNull Function<@NonNull C, @NonNull org.bukkit.command.CommandSender> backwardsCommandSenderMapper) Construct a new Bukkit command manager- Parameters:
owningPlugin- Plugin that is constructing the manager. This will be used when registering the commands to the Bukkit command map.commandExecutionCoordinator- Execution coordinator instance. The coordinator is in charge of executing incoming commands. Some considerations must be made when picking a suitable execution coordinator. For example, an entirely asynchronous coordinator is not suitable when the parsers used in your commands are not thread safe. If you have commands that perform blocking operations, however, it might not be a good idea to use a synchronous execution coordinator. In most cases you will want to pick betweenCommandExecutionCoordinator.simpleCoordinator()andAsynchronousCommandExecutionCoordinator.A word of caution: When using the asynchronous command executor in Bukkit, it is very likely that you will have to perform manual synchronization when executing the commands in many cases, as Bukkit makes no guarantees of thread safety in common classes. To make this easier,
taskRecipe()is provided. Furthermore, it may be unwise to use asynchronous command parsing, especially when dealing with things such as players and entities. To make this more safe, the asynchronous command execution allows you to state that you want synchronous command parsing.commandSenderMapper- Function that mapsCommandSenderto the command sender typebackwardsCommandSenderMapper- Function that maps the command sender type toCommandSender- Throws:
Exception- If the construction of the manager fails
-
-
Method Details
-
createNative
public static @NonNull BukkitCommandManager<@NonNull org.bukkit.command.CommandSender> createNative(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull Function<@NonNull cloud.commandframework.CommandTree<@NonNull org.bukkit.command.CommandSender>, @NonNull cloud.commandframework.execution.CommandExecutionCoordinator<@NonNull org.bukkit.command.CommandSender>> commandExecutionCoordinator) throws ExceptionCreate a command manager using Bukkit'sCommandSenderas the sender type.- Parameters:
owningPlugin- plugin owning the command managercommandExecutionCoordinator- execution coordinator instance- Returns:
- a new command manager
- Throws:
Exception- If the construction of the manager fails- Since:
- 1.5.0
- See Also:
-
taskRecipe
public @NonNull cloud.commandframework.tasks.TaskRecipe taskRecipe()Create a new task recipe. This can be used to create chains of synchronous/asynchronous method calls- Returns:
- Task recipe
-
getOwningPlugin
public @NonNull org.bukkit.plugin.Plugin getOwningPlugin()Get the plugin that owns the manager- Returns:
- Owning plugin
-
createDefaultCommandMeta
Create default command meta data- Specified by:
createDefaultCommandMetain classcloud.commandframework.CommandManager<C>- Returns:
- Meta data
-
getCommandSenderMapper
public final @NonNull Function<@NonNull org.bukkit.command.CommandSender,@NonNull C> getCommandSenderMapper()Get the command sender mapper- Returns:
- Command sender mapper
-
hasPermission
- Specified by:
hasPermissionin classcloud.commandframework.CommandManager<C>
-
getSplitAliases
protected final boolean getSplitAliases() -
setSplitAliases
protected final void setSplitAliases(boolean value) -
checkBrigadierCompatibility
protected final void checkBrigadierCompatibility() throws BukkitCommandManager.BrigadierFailureExceptionCheck whether Brigadier can be used on the server instance- Throws:
BukkitCommandManager.BrigadierFailureException- An exception is thrown if Brigadier isn't available. The exception will contain the reason for this.
-
queryCapability
@Deprecated @API(status=DEPRECATED, since="1.7.0") public final boolean queryCapability(@NonNull CloudBukkitCapabilities capability) Deprecated.for removal since 1.7.0. Use the new standardCommandManager.hasCapability(CloudCapability)instead.Query for a specific capability- Parameters:
capability- Capability- Returns:
trueif the manager has the given capability, elsefalse
-
queryCapabilities
Check for the platform capabilities- Returns:
- A set containing all capabilities of the instance
-
registerBrigadier
Attempt to register the Brigadier mapper, and return it.- Throws:
BukkitCommandManager.BrigadierFailureException- If Brigadier isn't supported by the platform
-
brigadierManager
- Specified by:
brigadierManagerin interfacecloud.commandframework.brigadier.BrigadierManagerHolder<C>- Since:
- 1.2.0
-
stripNamespace
Strip the plugin namespace from a plugin namespaced command. This will also strip the leading '/' if it's present- Parameters:
command- Command- Returns:
- Stripped command
-
getBackwardsCommandSenderMapper
public final @NonNull Function<@NonNull C,@NonNull org.bukkit.command.CommandSender> getBackwardsCommandSenderMapper()Get the backwards command sender plugin- Returns:
- The backwards command sender mapper
-