SnapshotCause
com.astralrealms.sync.model.snapshot.SnapshotCause
An enum representing the reason a player snapshot was created. Available in SnapshotCreatedEvent and stored in the snapshots database table.
Values
Value | Should Unload | Trigger |
|---|---|---|
| No | The player's very first snapshot — fired on initial join for new players |
| Yes | The player disconnected from the server |
| No | The player died |
| Yes | The server is shutting down (triggered during |
| No | Periodic world save event |
| No | An admin triggered a snapshot via the |
shouldUnload()
When true, AstralSync calls UnloadableSnapshotAdapter.unload() on every registered UnloadableSnapshotAdapter after the snapshot is saved. Use this in adapters that need to release resources (e.g. clearing caches, removing registrations) when a player fully leaves the server.
Causes that unload: DISCONNECT, SERVER_SHUTDOWN.
Causes that do not unload: INITIALIZATION, DEATH, WORLD_SAVE, MANUAL — the player remains online and data stays loaded.
Example Usage
Checking in an UnloadableSnapshotAdapter
AstralSync handles the shouldUnload() check internally — you do not need to check it yourself. Just implement UnloadableSnapshotAdapter and the unload() method will be called at the right time: