diff options
Diffstat (limited to 'src/main/java')
3 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/ReforgeAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/ReforgeAPI.kt index 987a864af..534d38d47 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/ReforgeAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/ReforgeAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.model.SkyblockStat import at.hannibal2.skyhanni.data.model.SkyblockStatList import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull @@ -176,7 +177,18 @@ object ReforgeAPI { while (reader.hasNext()) { val name = reader.nextName() val value = reader.nextDouble() - list[SkyblockStat.valueOf(name.uppercase())] = value + + val stat = SkyblockStat.getValueOrNull(name.uppercase()) ?: run { + ErrorManager.logErrorStateWithData( + "Unknown stat: '${name.uppercase()}'", + "Stat list could not parse stat", + "failed" to name.uppercase(), + betaOnly = true, + ) + continue + } + + list[stat] = value } reader.endObject() return list diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt b/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt index 182309634..f31c95958 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt @@ -53,6 +53,8 @@ enum class SkyblockStat(val icon: String) { FEAR("§a☠"), HEAT_RESISTANCE("§c♨"), + + UNKNOWN("§c?") ; val capitalizedName = name.lowercase().allLettersFirstUppercase() @@ -65,6 +67,10 @@ enum class SkyblockStat(val icon: String) { val fontSizeOfLargestIcon by lazy { entries.maxOf { Minecraft.getMinecraft().fontRendererObj.getStringWidth(it.icon) } + 1 } + + fun getValueOrNull(string: String): SkyblockStat? = entries.firstOrNull { it.name == string } + + fun getValue(string: String): SkyblockStat = getValueOrNull(string) ?: UNKNOWN } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt index 2048be522..13aec1d92 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt @@ -67,7 +67,7 @@ object SkyHanniTypeAdapters { val SKYBLOCK_STAT: TypeAdapter<SkyblockStat> = SimpleStringTypeAdapter( { name.lowercase() }, - { SkyblockStat.valueOf(this.uppercase()) }, + { SkyblockStat.getValue(this.uppercase()) }, ) val TRACKER_DISPLAY_MODE = SimpleStringTypeAdapter.forEnum<SkyHanniTracker.DefaultDisplayMode>() |