Package net.blueva.arcade.api.player
Interface GamePlayer<P>
- Type Parameters:
P- the player type (platform-specific)
public interface GamePlayer<P>
Represents a player participating in a game session.
GamePlayer wraps a platform-specific player object and provides game-specific state management, including player status (alive/spectator/eliminated) and custom data storage for game modules.
-
Method Summary
Modifier and TypeMethodDescriptionvoidClears all custom data for this player.voidEliminates this player from the game with a reason.<T> TRetrieves custom game-specific data for this player.Gets the underlying platform-specific player object.getState()Gets the current state of this player in the game.booleanChecks if custom data exists for a given key.booleanisAlive()Checks if the player is alive and actively playing.booleanChecks if the player has been eliminated from the game.booleanChecks if the player is spectating the game.voidConverts this player into a spectator.voidStores custom game-specific data for this player.voidsetState(PlayerState state) Sets the player's state.
-
Method Details
-
getPlayer
P getPlayer()Gets the underlying platform-specific player object.- Returns:
- the platform player
-
getState
PlayerState getState()Gets the current state of this player in the game.- Returns:
- the player's state (PLAYING, SPECTATOR, or ELIMINATED)
-
isAlive
boolean isAlive()Checks if the player is alive and actively playing.- Returns:
- true if the player is in PLAYING state
-
isSpectator
boolean isSpectator()Checks if the player is spectating the game.- Returns:
- true if the player is in SPECTATOR state
-
isEliminated
boolean isEliminated()Checks if the player has been eliminated from the game.- Returns:
- true if the player is in ELIMINATED state
-
setState
Sets the player's state.- Parameters:
state- the new player state
-
eliminate
Eliminates this player from the game with a reason.This sets the player state to ELIMINATED and fires a PlayerEliminateEvent.
- Parameters:
reason- the reason for elimination (for events/logging)
-
makeSpectator
void makeSpectator()Converts this player into a spectator.This sets the player state to SPECTATOR.
-
setData
Stores custom game-specific data for this player.Game modules can use this to store temporary player data that persists for the duration of the game session.
- Parameters:
key- the data keyvalue- the data value to store
-
getData
Retrieves custom game-specific data for this player.- Type Parameters:
T- the expected type- Parameters:
key- the data keytype- the class of the expected type- Returns:
- the stored value, or null if not found
-
hasData
Checks if custom data exists for a given key.- Parameters:
key- the data key to check- Returns:
- true if data exists for this key, false otherwise
-
clearData
void clearData()Clears all custom data for this player.
-