diff options
Diffstat (limited to 'platform-paper/src/main')
2 files changed, 14 insertions, 2 deletions
diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt index fc79ffe..6418f6f 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/listener/PlayerPresenceListener.kt @@ -95,6 +95,6 @@ class PlayerPresenceListener( channelManager?.setPlayerChannel(playerId, null) // 3. Trigger async save of player settings - playerSettingsManager.saveToDisk() + playerSettingsManager.queueSave() } } diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/settings/PlayerSettingsManager.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/settings/PlayerSettingsManager.kt index 9ee8d5a..110390d 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/settings/PlayerSettingsManager.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/settings/PlayerSettingsManager.kt @@ -66,8 +66,20 @@ class PlayerSettingsManager( } /** + * Queues a debounced asynchronous save without changing any setting. + * + * Used where the caller wants what is already in memory flushed soon - a player leaving, say - + * rather than paying for a write it does not need. + */ + fun queueSave() { + storage.queueAsyncSave(::snapshot) + } + + /** * Forces an immediate synchronous save of all settings to disk. - * This should only be called during plugin shutdown. + * + * Serializes every stored player and writes the whole file inline, so this belongs on the + * shutdown path only; everywhere else should use [queueSave] or [updateSettings]. */ fun saveToDisk() { storage.saveToDisk(snapshot()) |
