aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-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")