diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-16 12:34:18 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-16 12:34:18 +0200 |
| commit | 4293cfd919c3c93d4532534f722c407d7ad1370d (patch) | |
| tree | f9f612f021ef7f4283d74312edfaca30badc6749 /src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | |
| parent | 538e3ceb76f8e0b590291ce9aa90aa94896cdcb6 (diff) | |
| parent | 024ba52fb69b6cd44b4e31542867f802de656f15 (diff) | |
| download | SkyHanni-cum.tar.gz SkyHanni-cum.tar.bz2 SkyHanni-cum.zip | |
Merge branch 'beta' into cumcum
# Conflicts:
# src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
# src/main/java/at/hannibal2/skyhanni/config/features/AshfangConfig.java
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 18 |
1 files changed, 18 insertions, 0 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 d17a3dc6b..dfc69dee8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -21,6 +21,8 @@ class BazaarApi { var inBazaarInventory = false private var currentSearchedItem = "" + var currentlyOpenedProduct: NEUInternalName? = null + fun getBazaarDataByName(name: String): BazaarData? = NEUItems.getInternalNameOrNull(name)?.getBazaarData() fun NEUInternalName.getBazaarData() = if (isBazaarItem()) { @@ -45,6 +47,21 @@ class BazaarApi { @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { inBazaarInventory = checkIfInBazaar(event) + if (inBazaarInventory) { + val openedProduct = getOpenedProduct(event.inventoryItems) ?: return + currentlyOpenedProduct = openedProduct + BazaarOpenedProductEvent(openedProduct, event).postAndCatch() + } + } + + private fun getOpenedProduct(inventoryItems: Map<Int, ItemStack>): NEUInternalName? { + 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) } @SubscribeEvent @@ -118,5 +135,6 @@ class BazaarApi { @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { inBazaarInventory = false + currentlyOpenedProduct = null } }
\ No newline at end of file |
