From a84a1d72229688773f277a52bb5277bc58785447 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 20 Dec 2023 10:48:21 +0100 Subject: Bazaar best sell method now warns if an unknown bazaar item is detected. --- .../java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt | 4 ++-- src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 8 ++++---- .../at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt index a746d7468..e4995564d 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt @@ -2,5 +2,5 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.utils.NEUInternalName -class BazaarOpenedProductEvent(val openedProduct: NEUInternalName, val inventoryOpenEvent: InventoryFullyOpenedEvent) : - LorenzEvent() \ No newline at end of file +class BazaarOpenedProductEvent(val openedProduct: NEUInternalName?, val inventoryOpenEvent: InventoryFullyOpenedEvent) : + LorenzEvent() 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 0f14c98c3..a7dd3e845 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -58,20 +58,20 @@ class BazaarApi { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { inBazaarInventory = checkIfInBazaar(event) if (inBazaarInventory) { - val openedProduct = getOpenedProduct(event.inventoryItems) ?: return + val itemName = getOpenedProduct(event.inventoryItems) ?: return + val openedProduct = NEUItems.getInternalNameOrNull(itemName) currentlyOpenedProduct = openedProduct BazaarOpenedProductEvent(openedProduct, event).postAndCatch() } } - private fun getOpenedProduct(inventoryItems: Map): NEUInternalName? { + private fun getOpenedProduct(inventoryItems: Map): String? { val buyInstantly = inventoryItems[10] ?: return null if (buyInstantly.displayName != "§aBuy Instantly") return null val bazaarItem = inventoryItems[13] ?: return null - val itemName = bazaarItem.displayName - return NEUItems.getInternalNameOrNull(itemName) + return bazaarItem.displayName } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt index b42a331fe..f78b682d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt @@ -42,7 +42,10 @@ class BazaarBestSellMethod { display = updateDisplay(event.openedProduct) } - private fun updateDisplay(internalName: NEUInternalName): String { + private fun updateDisplay(internalName: NEUInternalName?): String { + if (internalName == null) { + return "§cUnknown Bazaar item!" + } try { var having = InventoryUtils.countItemsInLowerInventory { it.getInternalName() == internalName } lastClickedItem?.let { @@ -78,4 +81,4 @@ class BazaarBestSellMethod { } private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.bazaar.bestSellMethod -} \ No newline at end of file +} -- cgit