diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-26 17:43:12 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-26 17:43:12 +0100 |
commit | c5a0d1daf0138fc1d3ad4c7253d139258edca7d6 (patch) | |
tree | 34e488e2eacf439573af43e5dc5cd0cf2f005980 | |
parent | f812ba2e0b6320ac21d477ba8e35d7cfc7accd4c (diff) | |
download | skyhanni-c5a0d1daf0138fc1d3ad4c7253d139258edca7d6.tar.gz skyhanni-c5a0d1daf0138fc1d3ad4c7253d139258edca7d6.tar.bz2 skyhanni-c5a0d1daf0138fc1d3ad4c7253d139258edca7d6.zip |
Reworked isInBazaar check. Fixed Hide Not Clickable Items show in skyblock level guide inventory.
4 files changed, 48 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index c960b330d..dc29df890 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -93,8 +93,8 @@ public class SkyHanniMod { logger = LogManager.getLogger("SkyHanni"); //API and utils - new BazaarApi(); loadModule(this); + loadModule(new BazaarApi()); loadModule(new ChatManager()); loadModule(new HyPixelData()); loadModule(new DungeonData()); 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 857305c27..234498d5d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -1,32 +1,21 @@ package at.hannibal2.skyhanni.features.bazaar +import at.hannibal2.skyhanni.data.InventoryData +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class BazaarApi { companion object { val bazaarMap = mutableMapOf<String, BazaarData>() - - fun isBazaarInventory(inventoryName: String): Boolean { - if (inventoryName.contains(" ➜ ") && !inventoryName.contains("Museum")) return true - if (BazaarOrderHelper.isBazaarOrderInventory(inventoryName)) return true - - return when (inventoryName) { - "Your Bazaar Orders" -> true - "How many do you want?" -> true - "How much do you want to pay?" -> true - "Confirm Buy Order" -> true - "Confirm Instant Buy" -> true - "At what price are you selling?" -> true - "Confirm Sell Offer" -> true - "Order options" -> true - - else -> false - } - } + var inBazaarInventory = false fun getCleanBazaarName(name: String): String { if (name.endsWith(" Gemstone")) { @@ -53,6 +42,44 @@ class BazaarApi { } } + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + inBazaarInventory = checkIfInBazaar(event.inventory) + } + + private fun checkIfInBazaar(inventory: InventoryData.Inventory): Boolean { + val returnItem = inventory.slotCount - 5 + for ((slot, item) in inventory.items) { + if (slot == returnItem) { + if (item.name?.removeColor().let { it == "Go Back" }) { + val lore = item.getLore() + if (lore.getOrNull(0)?.removeColor().let { it == "To Bazaar" }) { + return true + } + } + } + } + + val title = inventory.title + if (title.startsWith("Bazaar ➜ ")) return true + return when (title) { + "How many do you want?" -> true + "How much do you want to pay?" -> true + "Confirm Buy Order" -> true + "Confirm Instant Buy" -> true + "At what price are you selling?" -> true + "Confirm Sell Offer" -> true + "Order options" -> true + + else -> false + } + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inBazaarInventory = false + } + init { BazaarDataGrabber(bazaarMap).start() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt index a60af8ec8..3c3844ac5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.BazaarUpdateEvent -import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.TimeUnit @@ -23,7 +22,7 @@ class BazaarUpdateTimer { @SubscribeEvent(priority = EventPriority.LOWEST) fun renderOverlay(event: GuiScreenEvent.BackgroundDrawnEvent) { if (!isEnabled()) return - if (!BazaarApi.isBazaarInventory(InventoryUtils.openInventoryName())) return + if (!BazaarApi.inBazaarInventory) return val duration = 10_000 - (System.currentTimeMillis() - lastBazaarUpdateTime) val format = if (duration < 0) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 8bc1ffe7e..685512cd1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -394,7 +394,7 @@ class HideNotClickableItems { } private fun hideBazaarOrAH(chestName: String, stack: ItemStack): Boolean { - val bazaarInventory = BazaarApi.isBazaarInventory(chestName) + val bazaarInventory = BazaarApi.inBazaarInventory val auctionHouseInventory = chestName == "Co-op Auction House" || chestName == "Auction House" || chestName == "Create BIN Auction" || chestName == "Create Auction" |