Interface PlayerExecutor


public interface PlayerExecutor
The player executor is used to perform various platform dependent actions. The player executor must be distinguished in two ways:
  • A global player executor performs the actions for all players connected to the network. It can be recognized by the fact that it uses the GLOBAL_UNIQUE_ID as its unique id. The global player executor can be obtained with PlayerManager.globalPlayerExecutor().
  • A player executor, who executes the actions for a specific player and only as long as the player is online. The per player executor can be obtained with PlayerManager.playerExecutor(UUID)
Since:
4.0
  • Field Details

    • GLOBAL_UNIQUE_ID

      static final UUID GLOBAL_UNIQUE_ID
  • Method Details

    • uniqueId

      @NonNull @NonNull UUID uniqueId()
      Gets the unique id of this player executor. The ID of the player executor equals the unique id of the player this executor is for.

      A global player executor that performs the action for all players is identified by the GLOBAL_UNIQUE_ID.

      Returns:
      the unique id of the player executor.
    • connect

      void connect(@NonNull @NonNull String serviceName)
      Connects the player associated with this player executor to the given service.
      Parameters:
      serviceName - the service to connect the player to.
      Throws:
      NullPointerException - if the given service name is null.
    • connectSelecting

      void connectSelecting(@NonNull @NonNull ServerSelectorType selectorType)
      Connects the player associated with this player executor to any service running the cluster. The service is chosen by the given server selector.
      Parameters:
      selectorType - the selector used for the service selection.
      Throws:
      NullPointerException - if the selector type is null.
    • connectToFallback

      void connectToFallback()
      Connects the player associated with this player executor to the best matching fallback.
    • connectToGroup

      void connectToGroup(@NonNull @NonNull String group, @NonNull @NonNull ServerSelectorType selectorType)
      Connects the player associated with this player executor to any service having the given group assigned. The service is chosen by the given server selector.
      Parameters:
      group - the group a service has to have.
      selectorType - the selector used for the service selection.
      Throws:
      NullPointerException - if the given group or selector is null.
    • connectToTask

      void connectToTask(@NonNull @NonNull String task, @NonNull @NonNull ServerSelectorType selectorType)
      Connects the player associated with this player executor to any service having the given task assigned. The service is chosen by the given server selector.
      Parameters:
      task - the task the service has to have.
      selectorType - the selector used for the service selection.
      Throws:
      NullPointerException - if the given group or selector is null.
    • kick

      void kick(@NonNull @NonNull Component message)
      Kicks the player associated with this player executor and the component as reason.
      Parameters:
      message - the message to display in the disconnect screen.
      Throws:
      NullPointerException - if the given message is null.
    • sendTitle

      void sendTitle(@NonNull @NonNull Title title)
      Sends the given title to the player associated with this player executor.
      Parameters:
      title - the title to display to the player.
      Throws:
      NullPointerException - if the given title is null.
    • sendChatMessage

      default void sendChatMessage(@NonNull @NonNull Component message)
      Sends the given message component as chat message to the player associated with this player executor.

      This method is equivalent to calling playerExecutor.sendChatMessage(message, null).

      Parameters:
      message - the message to send to the player.
      Throws:
      NullPointerException - if the given component is null.
    • sendChatMessage

      void sendChatMessage(@NonNull @NonNull Component message, @Nullable @Nullable String permission)
      Sends the given message component as chat message to the player associated with this player executor.

      If a permission is given the player is required to have the permission, otherwise the message is not sent.

      Parameters:
      message - the message to send to the player.
      permission - the permission required to get the message.
      Throws:
      NullPointerException - if the given component is null.
    • sendPluginMessage

      void sendPluginMessage(@NonNull @NonNull String key, byte[] data)
      Sends a plugin channel message to the player associated with this player executor using the given channel and data. The channel used has to be registered on the service software.
      Parameters:
      key - the channel to send the plugin message in.
      data - the data to send to the player.
      Throws:
      NullPointerException - if the given channel or data is null.
    • spoofCommandExecution

      default void spoofCommandExecution(@NonNull @NonNull String command)
      Spoofs the command execution for the player associated with this player executor. The given command input should not contain a leading slash as it is added on the fly.

      The command is executed on the proxy and if no command was found the command is redirected to the downstream service the player is connected to.

      Note: This method is equivalent to calling playerExecutor.spoofCommandExecution(command, true)

      Parameters:
      command - the command to execute for the player.
      Throws:
      NullPointerException - if the given command is null.
    • spoofCommandExecution

      void spoofCommandExecution(@NonNull @NonNull String command, boolean redirectToServer)
      Spoofs the command execution for the player associated with this player executor. The given command input should not contain a leading slash as it is added on the fly.

      If redirecting to the downstream service is desired the command is executed on the proxy first, if no command was found it is redirected to the downstream service the player is connected to.

      Parameters:
      command - the command to execute for the player.
      redirectToServer - whether to command should get redirected to the downstream.
      Throws:
      NullPointerException - if the given command is null.