From 760052709058d4f2c92d4caf3233f5bb0d6773ea Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 13 Jun 2024 17:38:06 +0200 Subject: Fix: Prefixes being incorrectly stripped from non-Kuudra armor items (#2057) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/misc/items/EstimatedItemValueCalculator.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 c18408a0f..2cb5835e6 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 @@ -103,13 +103,15 @@ object EstimatedItemValueCalculator { return Pair(totalPrice, basePrice) } + private fun isKuudraSet(internalName: String) = + (kuudraSets.any { internalName.contains(it) } && + listOf("CHESTPLATE", "LEGGINGS", "HELMET", "BOOTS").any { internalName.endsWith(it) }) + private fun addAttributeCost(stack: ItemStack, list: MutableList): Double { val attributes = stack.getAttributes() ?: return 0.0 - var internalName = stack.getInternalName().asString().removePrefix("VANQUISHED_") + var internalName = removeKuudraArmorPrefix(stack.getInternalName().asString().removePrefix("VANQUISHED_")) var genericName = internalName - if (kuudraSets.any { internalName.contains(it) } - && listOf("CHESTPLATE", "LEGGINGS", "HELMET", "BOOTS").any { internalName.endsWith(it) }) { - internalName = removeCrimsonArmorPrefix(internalName) + if (isKuudraSet(internalName)) { genericName = kuudraSets.fold(internalName) { acc, part -> acc.replace(part, "GENERIC_KUUDRA") } } if (internalName == "ATTRIBUTE_SHARD" && attributes.size == 1) { @@ -168,7 +170,9 @@ object EstimatedItemValueCalculator { return subTotal + 0.1 } - private fun removeCrimsonArmorPrefix(original: String): String { + private fun removeKuudraArmorPrefix(original: String): String { + if (!isKuudraSet(original)) return original + var internalName = original for (prefix in listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_")) { internalName = internalName.removePrefix(prefix) @@ -530,7 +534,7 @@ object EstimatedItemValueCalculator { } private fun addBaseItem(stack: ItemStack, list: MutableList): Double { - val internalName = removeCrimsonArmorPrefix(stack.getInternalName().asString()).asInternalName() + val internalName = removeKuudraArmorPrefix(stack.getInternalName().asString()).asInternalName() var price = internalName.getPrice() if (price == -1.0) { price = 0.0 -- cgit