diff options
| author | Walker Selby <git@walkerselby.com> | 2023-12-11 13:59:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-11 22:59:52 +0100 |
| commit | d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f (patch) | |
| tree | bc07923686b77da759b3f12ea535f2e3c02deead /src/main/java/at/hannibal2/skyhanni/features/rift | |
| parent | b8ec689ce9bd6fe89e4b825a988edb63fb51b5ab (diff) | |
| download | skyhanni-d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f.tar.gz skyhanni-d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f.tar.bz2 skyhanni-d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f.zip | |
Internal: Migrate Deprecated Config Values to Enums (#790)
Migrate Deprecated Config Values to Enums. #790
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt index 256349220..867e88dcd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.features.rift.everywhere.motes +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.rift.motes.InventoryValueConfig.NumberFormatEntry import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent @@ -9,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzColor @@ -163,14 +166,14 @@ class ShowMotesNpcSellPrice { } val total = itemMap.values.fold(0.0) { acc, pair -> acc + pair.second }.formatPrice() newDisplay.addAsSingletonList("§7Total price: §b$total") - val name = FormatType.entries[config.inventoryValue.formatType].type + val name = FormatType.entries[config.inventoryValue.formatType.ordinal].type // todo avoid ordinal newDisplay.addAsSingletonList("§7Price format: §c$name") newDisplay.addSelector<FormatType>( " ", getName = { type -> type.type }, - isCurrent = { it.ordinal == config.inventoryValue.formatType }, + isCurrent = { it.ordinal == config.inventoryValue.formatType.ordinal }, // todo avoid ordinal onChange = { - config.inventoryValue.formatType = it.ordinal + config.inventoryValue.formatType = NumberFormatEntry.entries[it.ordinal] // todo avoid ordinal update() } ) @@ -183,12 +186,19 @@ class ShowMotesNpcSellPrice { } private fun Double.formatPrice(): String = when (config.inventoryValue.formatType) { - 0 -> NumberUtil.format(this) - 1 -> this.addSeparators() + NumberFormatEntry.SHORT -> NumberUtil.format(this) + NumberFormatEntry.LONG -> this.addSeparators() else -> "0" } private fun isShowPriceEnabled() = RiftAPI.inRift() && config.showPrice private fun isInventoryValueEnabled() = RiftAPI.inRift() && config.inventoryValue.enabled + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "rift.motes.inventoryValue.formatType") { element -> + ConfigUtils.migrateIntToEnum(element, NumberFormatEntry::class.java) + } + } } |
