Java SDK — Players

Player Management

Players.registerPlayer
public static PlayerRegisterResponse registerPlayer(
    Client client,
    String name, 
    Object playerData
) throws IOException

Registers a new player with optional custom data. Uses generic type for player data with Jackson serialization.

Players.registerPlayerWithSteam
public static PlayerRegisterResponse registerPlayerWithSteam(
    Client client,
    String steamTicket,
    String steamIdentity,
    String name,
    Object playerData,
    String playerToken,
    boolean restore
) throws IOException

Registers or logs in a player via a hex-encoded Steam auth ticket from ISteamUser::GetAuthTicketForWebApi (single-use — request a fresh ticket each login). Requires Steam enabled for the project in the API cabinet; the account persists via SteamID. A ticket-only overload registerPlayerWithSteam(client, steamTicket) fills the rest with defaults. Response includes steam_id via getSteamId().

Ticket minting is out of scope for this SDK (server/tooling use): Java clients can mint via a Steamworks binding such as steamworks4j — SteamUser.getAuthTicketForWebApi(identity).

Players.registerPlayerWithGoogle
public static PlayerRegisterResponse registerPlayerWithGoogle(
    Client client,
    String googleAuthCode,
    String googleIntegrityToken,
    String name,
    Object playerData,
    String playerToken,
    boolean restore
) throws IOException

Registers or logs in via a Google Play Games server auth code. Pass restore true only after the player explicitly confirms a deletion-restore prompt; the fresh provider credential can recover the account even after a reinstall. Shorter overloads default restore to false.

Players.authenticatePlayer
public static <T> PlayerAuthResponse<T> authenticatePlayer(
    Client client,
    String playerToken,
    Class<T> dataType
) throws IOException

Authenticates a player using their private token. Returns player information with typed data support.

Games.getAllPlayers
public static PlayerListResponse getAllPlayers(
    Client client
) throws IOException

Retrieves a list of all players (requires private API token).

Players.sendPlayerHeartbeat
public static PlayerHeartbeatResponse sendPlayerHeartbeat(
    Client client,
    String playerToken
) throws IOException

Updates player heartbeat to maintain online status. Call every 30-60 seconds.

Players.logoutPlayer
public static PlayerLogoutResponse logoutPlayer(
    Client client,
    String playerToken
) throws IOException

Logs out a player and updates their last logout timestamp.

Players.renamePlayer
public static PlayerRenameResponse renamePlayer(
    Client client,
    String playerToken,
    String newName
) throws IOException

Renames a player to a new name. Validates name length (2-50 characters) and requires player authentication.

Players.deleteAccount
public static PlayerDeleteResponse deleteAccount(
    Client client,
    String playerToken
) throws IOException

Schedules player-initiated account deletion. The account freezes immediately and is purged after the 30-day grace window unless restored. Keep the player credential during the window; responses expose isDeletionPending() and getPurgeAfter().

Players.restoreAccount
public static PlayerRestoreResponse restoreAccount(
    Client client,
    String playerToken
) throws IOException

Cancels a pending deletion. This must be an explicit player action, never an automatic login or background retry. Provider-linked accounts can also restore after reinstall by signing in with the provider and restore set after confirmation.

Players.banPlayer
public static PlayerBanResponse banPlayer(
    Client client,
    int playerId,
    EBanTime banDuration,
    String banReason
) throws IOException

Bans a player from the game with specified duration (HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, FOREVER) and optional reason. Requires private API token.

Players.unbanPlayer
public static PlayerUnbanResponse unbanPlayer(
    Client client,
    int playerId
) throws IOException

Unbans a previously banned player. Requires private API token.

Ban.isBanned
public static boolean isBanned(ApiResponse response)

Checks if an API response indicates the player is banned. Returns true if the error message contains "You are banned".

Sessions, tokens and name rules

Register creates the player and returns the token your game stores and presents as X-Game-Player-Token. Login re-opens the session on a later run; heartbeat keeps the player marked online while they play; logout ends the session cleanly. Rotate issues a fresh credential and invalidates the old one — call it any time a token may have leaked.

Registration and rename validate the display name server-side against your game's name rules — allowed scripts, case policy and symbols, edited in the cabinet — plus the profanity screen. A rejected name comes back as a fielded error you can show the player instead of guessing why it failed.

  • Players register with just a display name — identity is the returned token, so store it like a credential.
  • Admin calls — list, ban and unban — use the API token pair. Never ship the private token in a client build.
  • Each player also carries a JSON data record — stats, loadouts, progression — that leaderboards rank server-side.
  • Calls return CompletableFuture — compose with thenApply/thenAccept, or join() on a worker thread when blocking is acceptable; never join on a UI or render thread.