diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-20 10:48:21 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-20 10:48:21 +0100 |
commit | a84a1d72229688773f277a52bb5277bc58785447 (patch) | |
tree | 88ec8af683f074e413388a8c1036fbfe2ea4c68b | |
parent | 0f0ad6b8ab8e9e8eee364ea7613e53d023e7b300 (diff) | |
download | skyhanni-a84a1d72229688773f277a52bb5277bc58785447.tar.gz skyhanni-a84a1d72229688773f277a52bb5277bc58785447.tar.bz2 skyhanni-a84a1d72229688773f277a52bb5277bc58785447.zip |
Bazaar best sell method now warns if an unknown bazaar item is detected.
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<Int, ItemStack>): NEUInternalName? { + private fun getOpenedProduct(inventoryItems: Map<Int, ItemStack>): 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 +} |