Class PlaytimeStorage
java.lang.Object
com.haven.havenplugin.playtime.PlaytimeStorage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteTmpSession(UUID uuid) voidfinalizeSession(UUID uuid, SessionData session, long endTime) Write the finalised session as<endTime>.jsonand deletetmp.json.voidinit()loadPlayerInfo(UUID uuid) LoadplayerInfo.jsonfor the given UUID.loadTmpSession(UUID uuid) Load a previously persisted live session.loadUUIDByUsername(String username) Resolve a player name to its UUID via the username index.voidsavePlayerInfo(UUID uuid, PlayerInfo info) Saveinfoatomically.voidsaveTmpSession(UUID uuid, SessionData session) Persist the live session state totmp.json.voidsaveUsernameIndex(String username, UUID uuid) Writeusername → uuidmapping used for offline player lookups.
-
Constructor Details
-
PlaytimeStorage
-
-
Method Details
-
init
public void init() -
loadPlayerInfo
LoadplayerInfo.jsonfor the given UUID.- Returns:
- the parsed
PlayerInfo, ornullif the file is absent or cannot be parsed.
-
savePlayerInfo
Saveinfoatomically. Creates the player directory if absent. -
saveUsernameIndex
-
loadUUIDByUsername
-
saveTmpSession
Persist the live session state totmp.json. -
loadTmpSession
Load a previously persisted live session.- Returns:
- the session, or
nullif absent / malformed.
-
deleteTmpSession
-
finalizeSession
Write the finalised session as<endTime>.jsonand deletetmp.json. Both operations are atomic individually; the order (write first, then delete) ensures no data loss on crash. -
getDataRoot
-