From 453f1149eae2fa417529b8792061d58b7e98bf81 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:56:32 +0100 Subject: Fixed hide non clickable items not working in some bazaar pages. --- .../java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 12 ++++-------- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 2 ++ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index 241d208a3..840253166 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.equalsIgnoreColor import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.gui.inventory.GuiChest @@ -119,14 +120,9 @@ class BazaarApi { } private fun checkIfInBazaar(event: InventoryFullyOpenedEvent): Boolean { - val returnItem = event.inventorySize - 5 - for ((slot, item) in event.inventoryItems) { - if (slot == returnItem && item.name?.removeColor().let { it == "Go Back" }) { - val lore = item.getLore() - if (lore.getOrNull(0)?.removeColor().let { it == "To Bazaar" }) { - return true - } - } + val items = event.inventorySize.let { listOf(it - 5, it - 6) }.mapNotNull { event.inventoryItems[it] } + if (items.any { it.name.equalsIgnoreColor("Go Back") && it.getLore().firstOrNull() == "§7To Bazaar" }) { + return true } if (event.inventoryName.startsWith("Bazaar ➜ ")) return true diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 4e85267ca..7c33cd1b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -286,4 +286,6 @@ object StringUtils { fun Pattern.find(string: String) = matcher(string).find() fun String.allLettersFirstUppercase() = split("_").joinToString(" ") { it.firstLetterUppercase() } + + fun String?.equalsIgnoreColor(string: String?) = this?.let { it.removeColor() == string?.removeColor() } ?: false } -- cgit