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.Gets all online players from the database.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
-
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
-