diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-07-15 16:45:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-15 16:45:09 +0200 |
| commit | ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f (patch) | |
| tree | 4a9786dd9c2578d0063ccd179200f04b612d7e35 /src/main/java/at/hannibal2/skyhanni/data | |
| parent | a716e5d26a6ae6c79300c298c221382fb73e21a8 (diff) | |
| download | skyhanni-ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f.tar.gz skyhanni-ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f.tar.bz2 skyhanni-ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f.zip | |
Fix: price source inconsistencies (bz sell/buy and npc price) (#2221)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt | 25 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt | 10 |
2 files changed, 8 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index b5d31185a..e392699cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType -import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.PriceFrom import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuSacksJson import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -22,7 +21,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal @@ -49,15 +47,15 @@ object SackAPI { private val patternGroup = RepoPattern.group("data.sacks") private val sackPattern by patternGroup.pattern( "sack", - "^(.* Sack|Enchanted .* Sack)\$" + "^(.* Sack|Enchanted .* Sack)\$", ) private val numPattern by patternGroup.pattern( "number", - "(?:(?:§[0-9a-f](?<level>I{1,3})§7:)?|(?:§7Stored:)?) (?<color>§[0-9a-f])(?<stored>[0-9.,kKmMbB]+)§7/(?<total>\\d+(?:[0-9.,]+)?[kKmMbB]?)" + "(?:(?:§[0-9a-f](?<level>I{1,3})§7:)?|(?:§7Stored:)?) (?<color>§[0-9a-f])(?<stored>[0-9.,kKmMbB]+)§7/(?<total>\\d+(?:[0-9.,]+)?[kKmMbB]?)", ) private val gemstonePattern by patternGroup.pattern( "gemstone", - " §[0-9a-f](?<gemrarity>[A-z]*): §[0-9a-f](?<stored>\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?" + " §[0-9a-f](?<gemrarity>[A-z]*): §[0-9a-f](?<stored>\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?", ) private var isRuneSack = false @@ -114,21 +112,14 @@ object SackAPI { SackDisplay.update(isNewInventory) } - private fun String.getTrophyRarity(): TrophyRarity? { - return if (this.startsWith("Bronze")) - TrophyRarity.BRONZE - else - if (this.startsWith("Silver")) - TrophyRarity.SILVER - else null + private fun String.getTrophyRarity(): TrophyRarity? = when { + this.startsWith("Bronze") -> TrophyRarity.BRONZE + this.startsWith("Silver") -> TrophyRarity.SILVER + else -> null } private fun NEUInternalName.sackPrice(stored: Int): Long { - return when (sackDisplayConfig.priceFrom) { - PriceFrom.BAZAAR -> (getPrice() * stored).toLong().coerceAtLeast(0) - PriceFrom.NPC -> (getNpcPriceOrNull() ?: 0.0).toLong() * stored - else -> 0L - } + return getPrice(sackDisplayConfig.priceSource).toLong() * stored } fun getSacksData(savingSacks: Boolean) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt index ab5f9cc78..71b60d76e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt @@ -1,13 +1,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils -import at.hannibal2.skyhanni.utils.ConfigUtils import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -39,11 +36,4 @@ object TrackerManager { hasChanged = false } } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.transform(17, "misc.tracker.priceFrom") { element -> - ConfigUtils.migrateIntToEnum(element, PriceFromEntry::class.java) - } - } } |
