diff options
-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 } |