Class TimeDAO

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

public class TimeDAO extends Object implements BaseDAO<TimeSQL>
Data Access Object for player playtime data in FlectonePulse. Handles playtime tracking and statistics for players.
Since:
1.9.0
  • Constructor Details

    • TimeDAO

      @Inject public TimeDAO(Database database)
  • 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<TimeSQL>
      Returns:
      the database instance
    • sqlClass

      public Class<? extends TimeSQL> sqlClass()
      Description copied from interface: BaseDAO
      Gets the SQL interface class for this DAO.
      Specified by:
      sqlClass in interface BaseDAO<TimeSQL>
      Returns:
      the SQL interface class
    • saveJoin

      public void saveJoin(@NonNull FPlayer fPlayer)
      Records a player's join If the player already exists, increments their session count; otherwise inserts a new playtime record.
      Parameters:
      fPlayer - the player who joined
    • saveSession

      public void saveSession(@NonNull PlayTime playTime)
      Records a player's session If the player already exists, increments their session count; otherwise inserts a new playtime record.
      Parameters:
      playTime - the playtime data to save
    • saveAfk

      public void saveAfk(@NonNull FPlayer fPlayer, boolean afk, PlayTime playTime)
      Updates total playtime with AFK. If the player is entering AFK, adds elapsed time to total and invert last seen. If the player is returning from AFK, updates the last seen timestamp.
      Parameters:
      fPlayer - the player whose AFK status is being updated
      afk - true if the player is going AFK, false if returning
    • saveQuit

      public void saveQuit(@NonNull FPlayer fPlayer, PlayTime playTime)
      Records a player's quit and updates total playtime.
      Parameters:
      fPlayer - the player who quit
    • getByPlayer

      public @NonNull Optional<PlayTime> getByPlayer(@NonNull FPlayer fPlayer)
      Gets playtime record for a player.
      Parameters:
      fPlayer - the player
      Returns:
      optional containing the playtime record
    • getTotalCount

      public int getTotalCount()
      Gets total number of playtime records.
      Returns:
      total count
    • getAllPlayTimes

      public @NonNull List<PlayTime> getAllPlayTimes(int limit, int offset)
      Gets all playtime records with player names.
      Returns:
      list of playtime records