diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-28 10:56:32 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-28 10:56:32 +0100 |
commit | 453f1149eae2fa417529b8792061d58b7e98bf81 (patch) | |
tree | ce9476b906d8eb0ef73d4ad46500a881eb2c5ac5 /src | |
parent | 0751af712913dd75977edfd51104d39058b39b38 (diff) | |
download | skyhanni-453f1149eae2fa417529b8792061d58b7e98bf81.tar.gz skyhanni-453f1149eae2fa417529b8792061d58b7e98bf81.tar.bz2 skyhanni-453f1149eae2fa417529b8792061d58b7e98bf81.zip |
Fixed hide non clickable items not working in some bazaar pages.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 12 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 2 |
2 files changed, 6 insertions, 8 deletions
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 } |