Klasse SavedDataManager
java.lang.Object
de.luckymcdev.foundryengine.common.savedata.SavedDataManager
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 -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifikator und TypMethodeBeschreibungnet.minecraft.nbt.CompoundTaggetData()net.minecraft.nbt.CompoundTaggetSection(String key) voidload()Loads the engine data from disk.voidsave()Immediately flushes pending server and client data to disk (called on server stop).voidsetData(net.minecraft.nbt.CompoundTag tag) Replaces the full engine data in memory.voidsetSection(String key, net.minecraft.nbt.CompoundTag section) Stores a section and marks the store dirty.voidRequests a broadcast of the full engine data.voidsyncToPlayer(net.minecraft.server.level.ServerPlayer player) Requests a broadcast of the full engine data.
-
Felddetails
-
FLUSH_INTERVAL_TICKS
public static final int FLUSH_INTERVAL_TICKS- Siehe auch:
-
-
Konstruktordetails
-
SavedDataManager
-
-
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
-
setSection
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 singleSavedDataSyncPacketto 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 withsyncToAll(); the data is always a full snapshot so sending to all players satisfies the per-player request.
-