diff options
Diffstat (limited to 'src/main')
3 files changed, 26 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java index dcbb65d15..10d97ebfd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java @@ -41,7 +41,7 @@ public class EstimatedItemValueConfig { @Expose @ConfigOption(name = "Show Exact Price", desc = "Show the exact total price instead of the compact number.") @ConfigEditorBoolean - public boolean exactPrice = false; + public Property<Boolean> exactPrice = Property.of(false); @Expose @ConfigOption(name = "Show Armor Value", desc = "Show the value of the full armor set in the Wardrobe inventory.") @@ -52,22 +52,22 @@ public class EstimatedItemValueConfig { @Expose @ConfigOption(name = "Ignore Helmet Skins", desc = "Ignore helmet Skins from the total value.") @ConfigEditorBoolean - public boolean ignoreHelmetSkins = false; + public Property<Boolean> ignoreHelmetSkins = Property.of(false); @Expose @ConfigOption(name = "Ignore Armor Dyes", desc = "Ignore Armor Dyes from the total value.") @ConfigEditorBoolean - public boolean ignoreArmorDyes = false; + public Property<Boolean> ignoreArmorDyes = Property.of(false); @Expose @ConfigOption(name = "Ignore Runes", desc = "Ignore Runes from the total value.") @ConfigEditorBoolean - public boolean ignoreRunes = false; + public Property<Boolean> ignoreRunes = Property.of(false); @Expose @ConfigOption(name = "Bazaar Price Source", desc = "Use Instant Buy or Buy Order.") @ConfigEditorDropdown - public BazaarPriceSource bazaarPriceSource = BazaarPriceSource.BUY_ORDER; + public Property<BazaarPriceSource> bazaarPriceSource = Property.of(BazaarPriceSource.BUY_ORDER); public enum BazaarPriceSource { INSTANT_BUY("Instant Buy"), @@ -92,7 +92,7 @@ public class EstimatedItemValueConfig { "This will drastically decrease the estimated value but might be correct when buying multiple low tier items and combining them." ) @ConfigEditorBoolean - public boolean useAttributeComposite = false; + public Property<Boolean> useAttributeComposite = Property.of(false); @Expose @ConfigLink(owner = EstimatedItemValueConfig.class, field = "enabled") 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) } } |