From 694d5334afbc3bfed8baf6e4f20de9c322f3423e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:26:56 +0100 Subject: Fixed Anita Medal Profit shop detecting wrong items. --- .../hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index 19d658c2a..9ec66e9f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -12,6 +12,8 @@ import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName @@ -20,6 +22,7 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -76,7 +79,7 @@ class AnitaMedalProfit { } private fun readItem(item: ItemStack, table: MutableMap, Pair>) { - val itemName = item.nameWithEnchantment ?: return + val itemName = getItemName(item) ?: return if (itemName == " ") return if (itemName == "§cClose") return if (itemName == "§eUnique Gold Medals") return @@ -101,6 +104,14 @@ class AnitaMedalProfit { table[Pair(itemName, "$color$format")] = Pair(profit, internalName) } + private fun getItemName(item: ItemStack): String? { + val name = item.name ?: return null + val isEnchantedBook = name.removeColor() == "Enchanted Book" + return if (isEnchantedBook) { + item.itemName + } else name + } + private fun getFullCost(requiredItems: MutableList): Double { val jacobTicketPrice = "JACOBS_TICKET".asInternalName().getPrice() var otherItemsPrice = 0.0 -- cgit