Interface CommandApi


public interface CommandApi
Registers and unregisters Plex commands.

Register commands during module load. Paper can then add them to the command list for the current server run. Module reloads on Paper reload datapacks to apply new command registrations. Folia requires a restart.

Modules must use the methods on PlexModule so that Plex can unregister their commands during module unload.

  • Method Details

    • register

      void register(PlexCommand command)
      Registers a command with Plex.
      Parameters:
      command - command to register
    • unregister

      void unregister(PlexCommand command)
      Unregisters a command from Plex.

      Plex removes this command's registered labels from Paper's live dispatcher. Labels replaced by another command remain unchanged.

      Parameters:
      command - command to unregister
    • registeredCommands

      List<PlexCommand> registeredCommands()
      Returns the commands tracked by Plex.
      Returns:
      registered commands
    • requiresLifecycleReload

      boolean requiresLifecycleReload()
      Checks if command changes require Paper to rebuild its command list.
      Returns:
      true if Paper must rebuild the command list
    • dispatchAsConsole

      boolean dispatchAsConsole(UUID identityId, String identityName, String command, Consumer<? super net.kyori.adventure.text.Component> feedback)
      Runs a command as the console and records the given actor. Call this method from the global server thread.
      Parameters:
      identityId - actor UUID
      identityName - actor name
      command - command line without a leading slash
      feedback - receiver for command feedback
      Returns:
      true if Paper accepted the command