From eebc1d00df5fa6cc56c09a1226ffa2a97d6af6f1 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:46:09 +1000 Subject: Fix + Backend: Sack Save (#469) --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 - src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 4bb551f87..83ef3360f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -423,7 +423,6 @@ class SkyHanniMod { initLogging() Runtime.getRuntime().addShutdownHook(Thread { configManager.saveConfig("shutdown-hook") - configManager.saveSackData("shutdown-hook") }) repo = RepoManager(configManager.configDirectory) try { diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index e2102c6ec..89363fd7c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -270,20 +270,20 @@ object SackAPI { sackData = sackData.editCopy { this[item] = SackItem(amount, 0, 0) } } - fun fetchSackItem(item: NEUInternalName): SackItem? { + fun fetchSackItem(item: NEUInternalName): SackItem { sackData = ProfileStorageData.sackProfiles?.sackContents ?: return SackItem(0, 0, -1) if (sackData.containsKey(item)) { - return sackData[item] + return sackData[item] ?: return SackItem(0, 0, -1) } sackData = sackData.editCopy { this[item] = SackItem(0, 0, 2) } - return sackData[item] + return sackData[item] ?: return SackItem(0, 0, -1) } private fun saveSackData() { ProfileStorageData.sackProfiles?.sackContents = sackData - SkyHanniMod.configManager.saveSackData("shutdown-hook") + SkyHanniMod.configManager.saveSackData("saving-data") } data class SackGemstone( -- cgit