Class FPlayerDAO
java.lang.Object
net.flectone.pulse.data.database.dao.FPlayerDAO
- All Implemented Interfaces:
BaseDAO<FPlayerSQL>
Data Access Object for player data in FlectonePulse.
Handles player registration, retrieval, and updates in the database.
- Since:
- 0.9.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents player information retrieved from the database. -
Constructor Summary
ConstructorsConstructorDescriptionFPlayerDAO(Database database, RandomGenerator randomGenerator, FLogger logger) -
Method Summary
Modifier and TypeMethodDescriptiondatabase()Gets the database instance associated with this DAO.getFPlayer(int id) Gets a player by database ID.getFPlayer(@NonNull String name) Gets a player by name.getFPlayer(@NonNull InetAddress inetAddress) Gets a player by IP address.getFPlayer(@NonNull UUID uuid) Gets a player by UUID.Gets all players from the database.getFPlayersByIp(@NonNull String ip, int limit, int offset) Gets a paginated list of players with the specified IP address.Gets all online players from the database.intgetTotalFPlayersCountByIp(@NonNull String ip) Gets the total count of players with the specified IP address.voidinsertOrIgnore(@NonNull FPlayer fPlayer) Inserts a player or ignores if already exists.insertOrUpdate(@NonNull UUID uuid, @NonNull String name, @Nullable String ip, boolean online) Inserts a new player into the database or updates an existing player.voidsetOfflineByServer(@NonNull String server) Sets all players associated with the specified server to offline status.Class<? extends FPlayerSQL> sqlClass()Gets the SQL interface class for this DAO.voidUpdates an existing player in the database.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseDAO
getSQL, inTransaction, useCustomTransaction, useHandle, useTransaction, withHandle
-
Constructor Details
-
FPlayerDAO
-
-
Method Details
-
database
Description copied from interface:BaseDAOGets the database instance associated with this DAO.- Specified by:
databasein interfaceBaseDAO<FPlayerSQL>- Returns:
- the database instance
-
sqlClass
Description copied from interface:BaseDAOGets the SQL interface class for this DAO.- Specified by:
sqlClassin interfaceBaseDAO<FPlayerSQL>- Returns:
- the SQL interface class
-
insertOrUpdate
public FPlayer insertOrUpdate(@NonNull UUID uuid, @NonNull String name, @Nullable String ip, boolean online) Inserts a new player into the database or updates an existing player. Handles conflicts by checking for existing records with the same UUID or name.- Parameters:
uuid- the player's UUIDname- the player's nameip- the player's IP address, can be nullonline- whether the player is currently online- Returns:
- the created or updated FPlayer object with assigned database ID
-
insertOrIgnore
Inserts a player or ignores if already exists.- Parameters:
fPlayer- the player to insert
-
update
Updates an existing player in the database.- Parameters:
fPlayer- the player to update
-
setOfflineByServer
Sets all players associated with the specified server to offline status.- Parameters:
server- the server identifier to match against player server settings
-
getOnlineFPlayers
-
getTotalFPlayersCountByIp
Gets the total count of players with the specified IP address.- Parameters:
ip- the IP address to count players for- Returns:
- the total number of players with the given IP, or 0 if the database is closed
-
getFPlayersByIp
Gets a paginated list of players with the specified IP address.- Parameters:
ip- the IP address to filter players bylimit- the maximum number of players to returnoffset- the number of players to skip- Returns:
- list of players matching the IP, ordered by ID descending, or an empty list if the database is closed
-
getFPlayers
-
getFPlayer
-
getFPlayer
Gets a player by IP address.- Parameters:
inetAddress- the IP address- Returns:
- the player or FPlayer.UNKNOWN if not found
-
getFPlayer
-
getFPlayer
Gets a player by database ID.- Parameters:
id- the player database ID- Returns:
- the player or FPlayer.UNKNOWN if not found
-