Klasse 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.

  • Feldübersicht

    Felder
    Modifikator und Typ
    Feld
    Beschreibung
    static final int
     
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
     
  • Methodenübersicht

    Modifikator und Typ
    Methode
    Beschreibung
    net.minecraft.nbt.CompoundTag
     
    net.minecraft.nbt.CompoundTag
     
    void
    Loads the engine data from disk.
    void
    Immediately flushes pending server and client data to disk (called on server stop).
    void
    setData(net.minecraft.nbt.CompoundTag tag)
    Replaces the full engine data in memory.
    void
    setSection(String key, net.minecraft.nbt.CompoundTag section)
    Stores a section and marks the store dirty.
    void
    Requests a broadcast of the full engine data.
    void
    syncToPlayer(net.minecraft.server.level.ServerPlayer player)
    Requests a broadcast of the full engine data.

    Von Klasse geerbte Methoden Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • FLUSH_INTERVAL_TICKS

      public static final int FLUSH_INTERVAL_TICKS
      Siehe auch:
  • Konstruktordetails

    • SavedDataManager

      public SavedDataManager(NetworkManager networkManager)
  • Methodendetails

    • 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. Coalesced: the next server tick sends a single SavedDataSyncPacket to all players if anything changed since the last send.
    • syncToPlayer

      public void syncToPlayer(net.minecraft.server.level.ServerPlayer player)
      Requests a broadcast of the full engine data. Coalesced with syncToAll(); the data is always a full snapshot so sending to all players satisfies the per-player request.