From c0172bcf3e94ac6a701820d2debda082680f957a Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 4 Nov 2023 08:56:19 +1100 Subject: cleaned up some config stuff and fixed a bug (#682) Fixed the crop name gets replaced to internal name in /shwords. #682 --- .../at/hannibal2/skyhanni/config/ConfigManager.kt | 30 ++-------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index bfbeb08df..498b2f489 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.config import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity -import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzRarity @@ -126,16 +125,9 @@ class ConfigManager { try { val inputStreamReader = InputStreamReader(FileInputStream(configFile!!), StandardCharsets.UTF_8) val bufferedReader = BufferedReader(inputStreamReader) - val builder = StringBuilder() - for (line in bufferedReader.lines()) { - val result = fixConfig(line) - builder.append(result) - builder.append("\n") - } - logger.log("load-config-now") - val jsonObject = gson.fromJson(builder.toString(), JsonObject::class.java) + val jsonObject = gson.fromJson(bufferedReader.readText(), JsonObject::class.java) val newJsonObject = ConfigUpdaterMigrator.fixConfig(jsonObject) features = gson.fromJson( newJsonObject, @@ -160,16 +152,10 @@ class ConfigManager { try { val inputStreamReader = InputStreamReader(FileInputStream(sackFile!!), StandardCharsets.UTF_8) val bufferedReader = BufferedReader(inputStreamReader) - val builder = StringBuilder() - for (line in bufferedReader.lines()) { - builder.append(line) - builder.append("\n") - } - logger.log("load-sacks-now") sackData = gson.fromJson( - builder.toString(), + bufferedReader.readText(), SackData::class.java ) logger.log("Loaded sacks from file") @@ -205,18 +191,6 @@ class ConfigManager { ) } - private fun fixConfig(line: String): String { - var result = line - for (type in CropType.entries) { - val normal = "\"${type.cropName}\"" - val enumName = "\"${type.name}\"" - while (result.contains(normal)) { - result = result.replace(normal, enumName) - } - } - return result - } - fun saveConfig(reason: String) { if (disableSaving) return logger.log("saveConfig: $reason") -- cgit