Interface Player

All Superinterfaces:
CommandSource, PermissionSubject

public interface Player extends CommandSource
Represents a player connected to the proxy.

Players are command sources and permission subjects, meaning they can execute commands and be checked for permissions using PermissionSubject.hasPermission(String) or PermissionSubject.getPermissionValue(String).

Since Player extends CommandSource, players can be used anywhere a command source is expected.

  • Method Details

    • getUniqueId

      @Nonnull UUID getUniqueId()
      Get the player's UUID.
      Returns:
      the player's UUID
    • getUsername

      @Nonnull String getUsername()
      Get the player's username.
      Returns:
      the username
    • getRemoteAddress

      @Nonnull InetSocketAddress getRemoteAddress()
      Get the player's remote address.
      Returns:
      the address the player connected from
    • getCurrentServer

      @Nonnull Optional<RegisteredServer> getCurrentServer()
      Get the server the player is currently connected to.
      Returns:
      the current server, or empty if not connected to any backend
    • isConnected

      boolean isConnected()
      Check if the player is currently connected.
      Returns:
      true if connected
    • getPing

      long getPing()
      Get the player's ping/latency in milliseconds.
      Returns:
      the ping in milliseconds, or -1 if unknown
    • sendPacket

      void sendPacket(@Nonnull Object packet)
      Send a packet to the player's client.
      Parameters:
      packet - the packet to send
    • sendPacketToServer

      void sendPacketToServer(@Nonnull Object packet)
      Send a packet to the backend server on behalf of this player.
      Parameters:
      packet - the packet to send
    • sendMessage

      void sendMessage(@Nonnull String message)
      Send a chat message to the player.
      Specified by:
      sendMessage in interface CommandSource
      Parameters:
      message - the message to send
    • sendMessage

      void sendMessage(@Nonnull ChatMessageBuilder builder)
      Send a formatted chat message to the player.

      Example usage:

      player.sendMessage(ChatMessageBuilder.create()
          .green("[Success] ")
          .white("Operation completed!"));
      
      Specified by:
      sendMessage in interface CommandSource
      Parameters:
      builder - the ChatMessageBuilder with the formatted message
    • disconnect

      void disconnect(@Nonnull String reason)
      Disconnect the player with a reason.
      Parameters:
      reason - the disconnect reason to show the player
    • transfer

      @Nonnull CompletableFuture<TransferResult> transfer(@Nonnull RegisteredServer server)
      Transfer the player to a different backend server.
      Parameters:
      server - the server to transfer to
      Returns:
      a future that completes when the transfer is initiated
    • transfer

      @Nonnull CompletableFuture<TransferResult> transfer(@Nonnull String serverName)
      Transfer the player to a different backend server by name.
      Parameters:
      serverName - the name of the server to transfer to
      Returns:
      a future that completes when the transfer is initiated
    • getProtocolHash

      @Nullable String getProtocolHash()
      Get the protocol hash the player is using.
      Returns:
      the protocol hash, or null if unknown
    • getSessionId

      long getSessionId()
      Get the session ID for this player's connection.
      Returns:
      the internal session ID
    • getPlayerSettings

      @Nonnull PlayerSettings getPlayerSettings()
      Get the player's settings/preferences.

      Settings include locale, client type, and other information extracted from the Connect packet.

      Example usage:

      Locale locale = player.getPlayerSettings().getLocale();
      String localizedMessage = getTranslation("welcome.message", locale);
      player.sendMessage(localizedMessage);
      
      Returns:
      the player's settings