Class PaperCommandManager<C>

java.lang.Object
cloud.commandframework.CommandManager<C>
cloud.commandframework.bukkit.BukkitCommandManager<C>
cloud.commandframework.paper.PaperCommandManager<C>
Type Parameters:
C - Command sender type
All Implemented Interfaces:
cloud.commandframework.brigadier.BrigadierManagerHolder<C>

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, cloud.commandframework.CommandManager.RegistrationState
  • Constructor Summary

    Constructors
    Constructor
    Description
    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)
    Construct a new Paper command manager
  • Method Summary

    Modifier and Type
    Method
    Description
    @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's CommandSender as the sender type.
    void
    Register asynchronous completions.
    void
    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, 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 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:
      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 Exception
      Create a command manager using Bukkit's CommandSender as the sender type.
      Parameters:
      owningPlugin - plugin owning the command manager
      commandExecutionCoordinator - 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.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
    • brigadierManager

      public @Nullable cloud.commandframework.brigadier.CloudBrigadierManager<C,​?> brigadierManager()
      Specified by:
      brigadierManager in interface cloud.commandframework.brigadier.BrigadierManagerHolder<C>
      Overrides:
      brigadierManager in class cloud.commandframework.bukkit.BukkitCommandManager<C>
      Since:
      1.2.0
    • registerAsynchronousCompletions

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