Class GraveLogger

java.lang.Object
com.haven.havenplugin.graves.GraveLogger

public class GraveLogger extends Object
Persists a historical record of recent graves. Files live at: data/graves//.yml
  • Constructor Details

    • GraveLogger

      public GraveLogger(Main plugin)
  • Method Details

    • logGrave

      public void logGrave(Grave grave)
      Writes a full log entry with status=ACTIVE. Call immediately after grave creation.
    • markDeleted

      public void markDeleted(UUID ownerId, UUID graveId, GraveRemoveReason reason)
      Updates the status field on an existing log entry. RESTORED is intentionally a no-op so the file keeps its previous status until reactivate(UUID, UUID, Location, long) is called.
    • reactivate

      public void reactivate(UUID ownerId, UUID graveId, org.bukkit.Location newLoc, long newExpiresAt)
      Marks the log ACTIVE again and updates coordinates + expiresAt after a restore.
    • loadGraveFromLog

      public Grave loadGraveFromLog(UUID ownerId, UUID graveId)
      Deserialises a full Grave from a log file for /graves restore. Returns null if the file does not exist, the world is unloaded, or parsing fails.
    • listLogs

      public List<Map.Entry<UUID, org.bukkit.configuration.file.YamlConfiguration>> listLogs(UUID ownerId)
      Returns all log entries for a player sorted by createdAt ascending. Each entry is (graveUUID → YamlConfiguration) so callers can read any field.
    • listGraveIds

      public List<String> listGraveIds(UUID ownerId)
      Returns logged grave UUID strings for a player (used for tab completion).
    • cleanupAsync

      public void cleanupAsync(long retentionMillis)
      Deletes log files whose createdAt predates the retention window. Runs asynchronously to avoid blocking the main thread.