From 4c12e4496fc3f6f49430a425cac52ce0b62b3fe5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 12 Dec 2023 20:46:32 +0100 Subject: Fixed finished city project still reminding and suggests buying items. --- .../skyhanni/features/fame/CityProjectFeatures.kt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index ace382885..62aa76289 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -82,9 +82,8 @@ class CityProjectFeatures { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!LorenzUtils.inSkyBlock) return - val lore = event.inventoryItems[4]?.getLore() ?: return - if (lore.isEmpty()) return - if (lore[0] != "§8City Project") return + inInventory = false + if (!inCityProject(event)) return inInventory = true if (config.showMaterials) { @@ -104,7 +103,9 @@ class CityProjectFeatures { for ((_, item) in event.inventoryItems) { val itemName = item.name ?: continue - for (line in item.getLore()) { + val lore = item.getLore() + if (lore.lastOrNull() == "§aProject is being built!") continue + for (line in lore) { contributeAgainPattern.matchMatcher(line) { val rawTime = group("time") if (rawTime.contains("Soon!")) return@matchMatcher @@ -122,6 +123,13 @@ class CityProjectFeatures { } } + private fun inCityProject(event: InventoryFullyOpenedEvent): Boolean { + val lore = event.inventoryItems[4]?.getLore() ?: return false + if (lore.isEmpty()) return false + if (lore[0] != "§8City Project") return false + return true + } + private fun buildList(materials: MutableMap) = buildList> { addAsSingletonList("§7City Project Materials") @@ -154,7 +162,9 @@ class CityProjectFeatures { private fun fetchMaterials(item: ItemStack, materials: MutableMap) { var next = false - for (line in item.getLore()) { + val lore = item.getLore() + if (lore.lastOrNull() == "§aProject is being built!") return + for (line in lore) { if (line == "§7Cost") { next = true continue -- cgit