Skip to content

Commit

Permalink
move friends data to config manager for saving
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed Nov 6, 2023
1 parent 801377d commit 899f20f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 899f20f

Please sign in to comment.