From 899f20fa274d0e575d0925d02a93173c37b079bf Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Mon, 6 Nov 2023 11:53:37 +1100 Subject: [PATCH] move friends data to config manager for saving --- src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt | 2 +- src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index 0df411ce3382..e84d82833643 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -199,7 +199,7 @@ class ConfigManager { saveFile(sackFile, "sacks", SkyHanniMod.sackData, reason) } - private fun saveFile(file: File?, fileName: String, data: Any, reason: String) { + fun saveFile(file: File?, fileName: String, data: Any, reason: String) { if (disableSaving) return logger.log("saveConfig: $reason") if (file == null) throw Error("Can not save $fileName, ${fileName}File is null!") diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index bca06d18cd76..274c3b18db77 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -60,7 +61,8 @@ class FriendAPI { } fun saveConfig() { - file.writeText(ConfigManager.gson.toJson(friendsJson)) + val friendsJsonCopy = friendsJson ?: return + SkyHanniMod.configManager.saveFile(file, "friends", friendsJsonCopy, "Save file") } @SubscribeEvent