diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt index 6901f8df66a5..40a30d70d5b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.StringUtils.addStrikethorugh import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -107,8 +108,9 @@ object ChocolateShopPrice { val internalName = item.getInternalName() val itemPrice = internalName.getPriceOrNull() ?: continue val otherItemsPrice = item.loreCosts().sumOf { it.getPrice() }.takeIf { it != 0.0 } + val canBeBought = lore.any { it == "§eClick to trade!" } - newProducts.add(Product(slot, item.itemName, internalName, chocolate, itemPrice, otherItemsPrice)) + newProducts.add(Product(slot, item.itemName, internalName, chocolate, itemPrice, otherItemsPrice, canBeBought)) } products = newProducts } @@ -141,10 +143,15 @@ object ChocolateShopPrice { add("") val formattedTimeUntilGoal = ChocolateAmount.CURRENT.formattedTimeUntilGoal(product.chocolate) add("§7Time until affordable: §6$formattedTimeUntilGoal ") + + if (!product.canBeBought) { + add("") + add("§cCannot be bought!") + } } table.add( DisplayTableEntry( - "${product.name}§f:", + product.name.addStrikethorugh(!product.canBeBought), "§6§l$perFormat", factor, product.item, @@ -205,5 +212,6 @@ object ChocolateShopPrice { val chocolate: Long, val itemPrice: Double, val otherItemPrice: Double?, + val canBeBought: Boolean, ) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index e596c316eb0b..8e30c6672e3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText +import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RegexUtils.findAll @@ -525,4 +526,12 @@ object StringUtils { if (string.isEmpty()) return "" return if (string[0] in "aeiou") "an" else "a" } + + fun String.addStrikethorugh(strikethorugh: Boolean = true): String { + if (!strikethorugh) return this + + val firstColor = getFirstColorCode() + val clean = removeColor() + return "§$firstColor§m$clean" + } }