Class SavedDataManager

java.lang.Object
de.luckymcdev.foundryengine.common.savedata.SavedDataManager

public class SavedDataManager extends Object
Central persistence and sync for FoundryEngine's engine data.

Server-managed sections (areas, cutscenes, dialogue, waypoints) are persisted per world to <levelDir>/foundryengine/engine.dat (resolved on ServerStartedEvent). On first load of a world the legacy global file (Common.ENGINE_DATA) is imported once. Client-local sections (e.g. the hotkeys section) stay in the legacy global file so they survive across worlds and sessions; synced world data is kept in memory on the client.

Writes and broadcasts are deferred: mutations only mark the store dirty, and self-registered tick listeners flush the disk at most every FLUSH_INTERVAL_TICKS ticks and coalesce all syncToAll/syncToPlayer calls into a single SavedDataSyncPacket per tick.

  • Field Details

  • Constructor Details

    • SavedDataManager

      public SavedDataManager(NetworkManager networkManager)
  • Method Details

    • load

      public void load()
      Loads the engine data from disk. Uses the per-world file when a server has resolved it, otherwise falls back to the legacy global location until then.
    • save

      public void save()
      Immediately flushes pending server and client data to disk (called on server stop).
    • getData

      public net.minecraft.nbt.CompoundTag getData()
    • setData

      public void setData(net.minecraft.nbt.CompoundTag tag)
      Replaces the full engine data in memory. Client-local sections are preserved across the replacement so locally edited preferences survive server syncs.
    • getSection

      public net.minecraft.nbt.CompoundTag getSection(String key)
    • setSection

      public void setSection(String key, net.minecraft.nbt.CompoundTag section)
      Stores a section and marks the store dirty. Disk persistence is deferred: server-managed sections are flushed by the server tick listener, client-local sections by the client tick (or logout) listener.
    • syncToAll

      public void syncToAll()
      Requests a broadcast of the full engine data. The snapshot is sent to all players, so there is no need for a per-player variant: any targeted request is a subset of this broadcast.