diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-07-06 10:52:25 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-07-06 10:52:25 +0200 |
| commit | 7c488b9741ca089e4419a5cc1ea44bad99ae6cea (patch) | |
| tree | 4de99fd7b43089b231af630b4859c30567dfb969 /src/main/java/at/hannibal2/skyhanni/features | |
| parent | 63c89c9f4b00228362473180ddf91461a340ca1f (diff) | |
| download | skyhanni-7c488b9741ca089e4419a5cc1ea44bad99ae6cea.tar.gz skyhanni-7c488b9741ca089e4419a5cc1ea44bad99ae6cea.tar.bz2 skyhanni-7c488b9741ca089e4419a5cc1ea44bad99ae6cea.zip | |
resetting estimated item value cache on config update
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt | 18 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt | 11 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 711b126a5..21b86b6cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle +import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -116,8 +116,18 @@ object EstimatedItemValue { @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { - config.enchantmentsCap.onToggle { - cache.clear() + with(config) { + ConditionalUtils.onToggle( + enchantmentsCap, + exactPrice, + ignoreHelmetSkins, + ignoreArmorDyes, + ignoreRunes, + bazaarPriceSource, + useAttributeComposite, + ) { + cache.clear() + } } } @@ -206,7 +216,7 @@ object EstimatedItemValue { if (basePrice == totalPrice) return listOf() - val numberFormat = if (config.exactPrice) { + val numberFormat = if (config.exactPrice.get()) { totalPrice.roundToLong().addSeparators() } else { totalPrice.shortFormat() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index 54f8f675e..bfc42659f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -51,6 +51,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasWoodSingularity import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase import io.github.moulberry.notenoughupdates.recipes.Ingredient +import io.github.notenoughupdates.moulconfig.observer.Property import net.minecraft.item.ItemStack import java.util.Locale @@ -208,7 +209,7 @@ object EstimatedItemValueCalculator { private fun String.fixMending() = if (this == "MENDING") "VITALITY" else this private fun getPriceOrCompositePriceForAttribute(attributeName: String, level: Int): Double? { - val intRange = if (config.useAttributeComposite) 1..10 else level..level + val intRange = if (config.useAttributeComposite.get()) 1..10 else level..level return intRange.mapNotNull { lowerLevel -> "$attributeName;$lowerLevel".asInternalName().getPriceOrNull() ?.let { it / (1 shl lowerLevel) * (1 shl level).toDouble() } @@ -480,18 +481,18 @@ object EstimatedItemValueCalculator { internalName: NEUInternalName, list: MutableList<String>, label: String, - shouldIgnorePrice: Boolean, + shouldIgnorePrice: Property<Boolean>, ): Double { val price = internalName.getPrice() val name = internalName.getNameOrRepoError() val displayName = name ?: "§c${internalName.asString()}" - val color = if (shouldIgnorePrice) "§7" else "§6" + val color = if (shouldIgnorePrice.get()) "§7" else "§6" list.add("§7$label: $displayName §7($color" + price.shortFormat() + "§7)") if (name == null) { list.add(" §8(Not yet in NEU Repo)") } - return if (shouldIgnorePrice) 0.0 else price + return if (shouldIgnorePrice.get()) 0.0 else price } private fun addEnrichment(stack: ItemStack, list: MutableList<String>): Double { @@ -759,7 +760,7 @@ object EstimatedItemValueCalculator { private fun NEUInternalName.getPrice(): Double = getPriceOrNull() ?: -1.0 private fun NEUInternalName.getPriceOrNull(): Double? { - val useSellPrice = config.bazaarPriceSource == EstimatedItemValueConfig.BazaarPriceSource.BUY_ORDER + val useSellPrice = config.bazaarPriceSource.get() == EstimatedItemValueConfig.BazaarPriceSource.BUY_ORDER return getPriceOrNull(useSellPrice) } } |
