Class PaperCommandManager<C>

  • Type Parameters:
    C - Command sender type

    public class PaperCommandManager<C>
    extends cloud.commandframework.bukkit.BukkitCommandManager<C>
    Paper command manager that extends 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
    • Constructor Summary

      Constructors 
      Constructor Description
      PaperCommandManager​(@NonNull org.bukkit.plugin.Plugin owningPlugin, @NonNull java.util.function.Function<cloud.commandframework.CommandTree<C>,​cloud.commandframework.execution.CommandExecutionCoordinator<C>> commandExecutionCoordinator, @NonNull java.util.function.Function<org.bukkit.command.CommandSender,​C> commandSenderMapper, @NonNull java.util.function.Function<C,​org.bukkit.command.CommandSender> backwardsCommandSenderMapper)
      Construct a new Paper command manager
    • Method Summary

      Modifier and Type Method Description
      void registerAsynchronousCompletions()
      Register asynchronous completions.
      void registerBrigadier()
      Register Brigadier mappings using the native paper events
      • Methods 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, executeCommand, flagBuilder, getCaptionRegistry, getCommandHelpHandler, getCommandRegistrationHandler, getCommands, getCommandSuggestionProcessor, getCommandSyntaxFormatter, getCommandTree, getExceptionHandler, getParserRegistry, getSetting, handleException, hasPermission, postprocessContext, preprocessContext, registerCommandPostProcessor, registerCommandPreProcessor, registerDefaultCaptions, registerExceptionHandler, setCaptionRegistry, setCommandRegistrationHandler, setCommandSuggestionProcessor, setCommandSyntaxFormatter, setSetting, suggest
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PaperCommandManager

        public PaperCommandManager​(@NonNull org.bukkit.plugin.Plugin owningPlugin,
                                   @NonNull java.util.function.Function<cloud.commandframework.CommandTree<C>,​cloud.commandframework.execution.CommandExecutionCoordinator<C>> commandExecutionCoordinator,
                                   @NonNull java.util.function.Function<org.bukkit.command.CommandSender,​C> commandSenderMapper,
                                   @NonNull java.util.function.Function<C,​org.bukkit.command.CommandSender> backwardsCommandSenderMapper)
                            throws java.lang.Exception
        Construct 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 between CommandExecutionCoordinator.simpleCoordinator() and AsynchronousCommandExecutionCoordinator.

        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 maps CommandSender to the command sender type
        backwardsCommandSenderMapper - Function that maps the command sender type to CommandSender
        Throws:
        java.lang.Exception - If the construction of the manager fails
    • Method Detail

      • registerBrigadier

        public void registerBrigadier()
                               throws cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureException
        Register Brigadier mappings using the native paper events
        Overrides:
        registerBrigadier in class cloud.commandframework.bukkit.BukkitCommandManager<C>
        Throws:
        cloud.commandframework.bukkit.BukkitCommandManager.BrigadierFailureException - Exception thrown if the mappings cannot be registered
      • registerAsynchronousCompletions

        public void registerAsynchronousCompletions()
                                             throws java.lang.IllegalStateException
        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:
        java.lang.IllegalStateException - when the server does not support asynchronous completions.
        See Also:
        Check if the capability is present