Class PaperCommandManager<C>
- Type Parameters:
C
- Command sender type
- All Implemented Interfaces:
cloud.commandframework.brigadier.BrigadierManagerHolder<C>
BukkitCommandManager
-
Nested Class Summary
Nested classes/interfaces inherited from class cloud.commandframework.bukkit.BukkitCommandManager
cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureException, cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureReason
Nested classes/interfaces inherited from class cloud.commandframework.CommandManager
cloud.commandframework.CommandManager.ManagerSettings, cloud.commandframework.CommandManager.RegistrationState
-
Constructor Summary
ConstructorDescriptionPaperCommandManager(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull Function<cloud.commandframework.CommandTree<C>,cloud.commandframework.execution.CommandExecutionCoordinator<C>> commandExecutionCoordinator, @NonNull Function<org.bukkit.command.CommandSender,C> commandSenderMapper, @NonNull Function<C,org.bukkit.command.CommandSender> backwardsCommandSenderMapper)
Construct a new Paper command manager -
Method Summary
Modifier and TypeMethodDescription@Nullable cloud.commandframework.brigadier.CloudBrigadierManager<C,?>
static @NonNull PaperCommandManager<@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'sCommandSender
as the sender type.void
Register asynchronous completions.void
Register Brigadier mappings using the native paper eventsMethods inherited from class cloud.commandframework.bukkit.BukkitCommandManager
checkBrigadierCompatibility, createDefaultCommandMeta, getBackwardsCommandSenderMapper, getCommandSenderMapper, getOwningPlugin, getSplitAliases, hasPermission, queryCapabilities, queryCapability, setSplitAliases, stripNamespace, taskRecipe
Methods inherited from class cloud.commandframework.CommandManager
argumentBuilder, command, command, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, commandBuilder, executeCommand, flagBuilder, getCaptionRegistry, getCommandHelpHandler, getCommandHelpHandler, getCommandRegistrationHandler, getCommands, getCommandSuggestionProcessor, getCommandSyntaxFormatter, getCommandTree, getExceptionHandler, getParserRegistry, getRegistrationState, getSetting, handleException, hasPermission, isCommandRegistrationAllowed, lockRegistration, parameterInjectorRegistry, postprocessContext, preprocessContext, registerCommandPostProcessor, registerCommandPreProcessor, registerDefaultCaptions, registerExceptionHandler, requireState, setCaptionRegistry, setCommandRegistrationHandler, setCommandSuggestionProcessor, setCommandSyntaxFormatter, setSetting, suggest, transitionIfPossible, transitionOrThrow
-
Constructor Details
-
PaperCommandManager
public PaperCommandManager(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull Function<cloud.commandframework.CommandTree<C>,cloud.commandframework.execution.CommandExecutionCoordinator<C>> commandExecutionCoordinator, @NonNull Function<org.bukkit.command.CommandSender,C> commandSenderMapper, @NonNull Function<C,org.bukkit.command.CommandSender> backwardsCommandSenderMapper) throws ExceptionConstruct a new Paper 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,
BukkitCommandManager.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.The execution coordinator will not have an impact on command suggestions. More specifically, using an asynchronous command executor does not mean that command suggestions will be provided asynchronously. Instead, use
registerAsynchronousCompletions()
to register asynchronous completions. This will only work on Paper servers. Be aware that cloud does not synchronize the command suggestions for you, and this should only be used if your command suggestion providers are thread safe.commandSenderMapper
- Function that mapsCommandSender
to 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 PaperCommandManager<@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'sCommandSender
as 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:
for a more thorough explanation
-
registerBrigadier
public void registerBrigadier() throws cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureExceptionRegister Brigadier mappings using the native paper events- Overrides:
registerBrigadier
in classcloud.commandframework.bukkit.BukkitCommandManager<C>
- Throws:
cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureException
- Exception thrown if the mappings cannot be registered
-
brigadierManager
-
registerAsynchronousCompletions
Register asynchronous completions. This requires all argument parsers to be thread safe, and it is up to the caller to guarantee that such is the case- Throws:
IllegalStateException
- when the server does not support asynchronous completions.- See Also:
Check if the capability is present
-