Class PlaytimeStorage

java.lang.Object
com.haven.havenplugin.playtime.PlaytimeStorage

public class PlaytimeStorage extends Object
  • Constructor Details

    • PlaytimeStorage

      public PlaytimeStorage(Main plugin)
  • Method Details

    • init

      public void init()
    • loadPlayerInfo

      public PlayerInfo loadPlayerInfo(UUID uuid)
      Load playerInfo.json for the given UUID.
      Returns:
      the parsed PlayerInfo, or null if the file is absent or cannot be parsed.
    • savePlayerInfo

      public void savePlayerInfo(UUID uuid, PlayerInfo info)
      Save info atomically. Creates the player directory if absent.
    • saveUsernameIndex

      public void saveUsernameIndex(String username, UUID uuid)
      Write username → uuid mapping used for offline player lookups.
    • loadUUIDByUsername

      public UUID loadUUIDByUsername(String username)
      Resolve a player name to its UUID via the username index.
      Returns:
      UUID or null if no mapping exists.
    • saveTmpSession

      public void saveTmpSession(UUID uuid, SessionData session)
      Persist the live session state to tmp.json.
    • loadTmpSession

      public SessionData loadTmpSession(UUID uuid)
      Load a previously persisted live session.
      Returns:
      the session, or null if absent / malformed.
    • deleteTmpSession

      public void deleteTmpSession(UUID uuid)
    • finalizeSession

      public void finalizeSession(UUID uuid, SessionData session, long endTime)
      Write the finalised session as <endTime>.json and delete tmp.json. Both operations are atomic individually; the order (write first, then delete) ensures no data loss on crash.
    • getDataRoot

      public Path getDataRoot()