Class PaperCommandManager<C>

    • Constructor Detail

      • PaperCommandManager

        public PaperCommandManager​(@NonNull Plugin owningPlugin,
                                   @NonNull Function<CommandTree<C>,​CommandExecutionCoordinator<C>> commandExecutionCoordinator,
                                   @NonNull Function<CommandSender,​C> commandSenderMapper,
                                   @NonNull Function<C,​CommandSender> backwardsCommandSenderMapper)
                            throws Exception
        Construct a new Paper command manager
        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
        Exception - If the construction of the manager fails