aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-11-04 08:56:19 +1100
committerGitHub <noreply@github.com>2023-11-03 22:56:19 +0100
commitc0172bcf3e94ac6a701820d2debda082680f957a (patch)
tree2c8ba6d6ff08896b446376e0dcafd6e491998e20 /src/main/java/at/hannibal2/skyhanni
parentdedbe709684dde6fa8e0c490bf1f97374c83e222 (diff)
downloadskyhanni-c0172bcf3e94ac6a701820d2debda082680f957a.tar.gz
skyhanni-c0172bcf3e94ac6a701820d2debda082680f957a.tar.bz2
skyhanni-c0172bcf3e94ac6a701820d2debda082680f957a.zip
cleaned up some config stuff and fixed a bug (#682)
Fixed the crop name gets replaced to internal name in /shwords. #682
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt30
1 files changed, 2 insertions, 28 deletions
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")