diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-06-19 19:48:18 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-19 11:48:18 +0200 |
| commit | 64e59b4a917f6d71868f3722f65700a592404388 (patch) | |
| tree | bbd256ba0f4bf9591cdff0e1bde416d98c7f4f9c /src/main/java/at/hannibal2/skyhanni/features/bazaar | |
| parent | b14d79c5a5e7d245398b7d697cef305bbbed2ad7 (diff) | |
| download | skyhanni-64e59b4a917f6d71868f3722f65700a592404388.tar.gz skyhanni-64e59b4a917f6d71868f3722f65700a592404388.tar.bz2 skyhanni-64e59b4a917f6d71868f3722f65700a592404388.zip | |
Merge pull request #241
* BazaarApi searching
* Highlight Item
* Resetting on purchase and only highlights correct one
* adding default value
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/bazaar')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 53 |
1 files changed, 52 insertions, 1 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 85267240e..9d6705da5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -1,12 +1,21 @@ package at.hannibal2.skyhanni.features.bazaar +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent 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.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -17,6 +26,7 @@ class BazaarApi { companion object { val holder = BazaarDataHolder() var inBazaarInventory = false + private var currentSearchedItem = "" fun getBazaarDataByName(name: String): BazaarData? = NEUItems.getInternalNameOrNull(name)?.let { getBazaarDataByInternalName(it) } @@ -32,6 +42,16 @@ class BazaarApi { fun isBazaarItem(internalName: String): Boolean { return NEUItems.manager.auctionManager.getBazaarInfo(internalName) != null } + + fun searchForBazaarItem(displayName: String, amount: Int = -1){ + if (!LorenzUtils.inSkyBlock) return + if (NEUItems.neuHasFocus()) return + if (LorenzUtils.noTradeMode) return + if (LorenzUtils.inDungeons || LorenzUtils.inKuudraFight) return + LorenzUtils.sendCommandToServer("bz ${displayName.removeColor()}") + if (amount != -1) OSUtils.copyToClipboard(amount.toString()) + currentSearchedItem = displayName.removeColor() + } } @SubscribeEvent @@ -39,7 +59,6 @@ class BazaarApi { inBazaarInventory = checkIfInBazaar(event) } - @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return @@ -50,6 +69,38 @@ class BazaarApi { } } + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!inBazaarInventory) return + if (!SkyHanniMod.feature.bazaar.purchaseHelper) return + if (currentSearchedItem == "") return + + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + + for (slot in chest.inventorySlots) { + if (slot == null) continue + val stack = slot.stack ?: continue + + if (chest.inventorySlots.indexOf(slot) !in 9..44) { + continue + } + + if (stack.displayName.removeColor() == currentSearchedItem) { + slot highlight LorenzColor.GREEN + } + } + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if ("\\[Bazaar] (Buy Order Setup!|Bought).*$currentSearchedItem.*".toRegex().matches(event.message.removeColor())) { + currentSearchedItem = "" + } + } + private fun checkIfInBazaar(event: InventoryOpenEvent): Boolean { val returnItem = event.inventorySize - 5 for ((slot, item) in event.inventoryItems) { |
