Class FPlayerDAO

java.lang.Object
net.flectone.pulse.data.database.dao.FPlayerDAO
All Implemented Interfaces:
BaseDAO<FPlayerSQL>

public class FPlayerDAO extends Object implements BaseDAO<FPlayerSQL>
Data Access Object for player data in FlectonePulse. Handles player registration, retrieval, and updates in the database.
Since:
0.9.0
  • Constructor Details

  • Method Details

    • database

      public Database database()
      Description copied from interface: BaseDAO
      Gets the database instance associated with this DAO.
      Specified by:
      database in interface BaseDAO<FPlayerSQL>
      Returns:
      the database instance
    • sqlClass

      public Class<? extends FPlayerSQL> sqlClass()
      Description copied from interface: BaseDAO
      Gets the SQL interface class for this DAO.
      Specified by:
      sqlClass in interface BaseDAO<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 UUID
      name - the player's name
      ip - the player's IP address, can be null
      online - whether the player is currently online
      Returns:
      the created or updated FPlayer object with assigned database ID
    • insertOrIgnore

      public void insertOrIgnore(@NonNull FPlayer fPlayer)
      Inserts a player or ignores if already exists.
      Parameters:
      fPlayer - the player to insert
    • update

      public void update(@NonNull FPlayer fPlayer)
      Updates an existing player in the database.
      Parameters:
      fPlayer - the player to update
    • setOfflineByServer

      public void setOfflineByServer(@NonNull String server)
      Sets all players associated with the specified server to offline status.
      Parameters:
      server - the server identifier to match against player server settings
    • getOnlineFPlayers

      public List<FPlayer> getOnlineFPlayers()
      Gets all online players from the database.
      Returns:
      list of online players
    • getFPlayers

      public List<FPlayer> getFPlayers()
      Gets all players from the database.
      Returns:
      list of all players
    • getFPlayer

      public FPlayer getFPlayer(@NonNull String name)
      Gets a player by name.
      Parameters:
      name - the player name
      Returns:
      the player or FPlayer.UNKNOWN if not found
    • getFPlayer

      public FPlayer getFPlayer(@NonNull InetAddress inetAddress)
      Gets a player by IP address.
      Parameters:
      inetAddress - the IP address
      Returns:
      the player or FPlayer.UNKNOWN if not found
    • getFPlayer

      public FPlayer getFPlayer(@NonNull UUID uuid)
      Gets a player by UUID.
      Parameters:
      uuid - the player UUID
      Returns:
      the player or FPlayer.UNKNOWN if not found
    • getFPlayer

      public FPlayer getFPlayer(int id)
      Gets a player by database ID.
      Parameters:
      id - the player database ID
      Returns:
      the player or FPlayer.UNKNOWN if not found