diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
6 files changed, 69 insertions, 23 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) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index 241f6cbcd..5c67ea67e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -3,19 +3,23 @@ package at.hannibal2.skyhanni.features.garden.composter import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.model.ComposterUpgrade import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel -import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson import at.hannibal2.skyhanni.utils.renderables.Renderable import io.github.moulberry.notenoughupdates.NotEnoughUpdates @@ -389,10 +393,9 @@ class ComposterOverlay { val name = itemName.substring(0, 2) + selected + rawItemName list.add(Renderable.link("$name§r §8x${itemsNeeded.addSeparators()} §7(§6$format§7)") { onClick(internalName) - if (LorenzUtils.isControlKeyDown() && !LorenzUtils.noTradeMode) { + if (LorenzUtils.isControlKeyDown()) { inInventory = false - LorenzUtils.sendCommandToServer("bz $rawItemName") - OSUtils.copyToClipboard("${itemsNeeded.toInt()}") + BazaarApi.searchForBazaarItem(itemName, itemsNeeded.toInt()) } }) bigList.add(list) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt index 36f67eab6..e04c0dc54 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt @@ -1,13 +1,12 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide.pages +import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneUpgrades import at.hannibal2.skyhanni.utils.GuiRenderUtils import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.MathHelper import java.text.DecimalFormat @@ -38,9 +37,7 @@ class UpgradePage: FFGuideGUI.FFGuidePage() { var formattedUpgrade = upgradeItem.nameWithEnchantment ?: return if (adjustedY + 25 * index - 5 < FFGuideGUI.lastClickedHeight && FFGuideGUI.lastClickedHeight < adjustedY + 25 * index + 10) { FFGuideGUI.lastClickedHeight = 0 - if (!NEUItems.neuHasFocus() && !LorenzUtils.noTradeMode) { - LorenzUtils.sendCommandToServer("bz ${formattedUpgrade.removeColor()}") - } + BazaarApi.searchForBazaarItem(formattedUpgrade, upgrade.itemQuantity) } if (upgrade.itemQuantity != 1) { formattedUpgrade = "$formattedUpgrade §fx${upgrade.itemQuantity}" diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 973f122d5..f7fedd18c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed @@ -175,9 +176,8 @@ class GardenVisitorFeatures { list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", { if (Minecraft.getMinecraft().currentScreen is GuiEditSign) { LorenzUtils.setTextIntoSign("$amount") - } else if (!NEUItems.neuHasFocus() && !LorenzUtils.noTradeMode) { - LorenzUtils.sendCommandToServer("bz ${name.removeColor()}") - OSUtils.copyToClipboard("$amount") + } else { + BazaarApi.searchForBazaarItem(name, amount) } }) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() }) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index 6f5678bc8..acb7d6b67 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -186,9 +186,7 @@ class SackDisplay { add(itemStack) if (!isTrophySack) add(Renderable.optionalLink("${itemName.replace("§k", "")}: ", { - if (!NEUItems.neuHasFocus() && !LorenzUtils.noTradeMode) { - LorenzUtils.sendCommandToServer("bz ${itemName.removeColor()}") - } + BazaarApi.searchForBazaarItem(itemName) }) { !NEUItems.neuHasFocus() }) else add("${itemName.replace("§k", "")}: ") @@ -254,9 +252,7 @@ class SackDisplay { add(" §7- ") add(NEUItems.getItemStack(internalName)) add(Renderable.optionalLink("$name: ", { - if (!NEUItems.neuHasFocus() && !LorenzUtils.noTradeMode) { - LorenzUtils.sendCommandToServer("bz ${name.removeColor().dropLast(1)}") - } + BazaarApi.searchForBazaarItem(name.dropLast(1)) }) { !NEUItems.neuHasFocus() }) add(" ($rough-§a$flawed-§9$fine-§5$flawless)") val price = (roughprice + flawedprice + fineprice + flawlessprice) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt index dee222aa2..d8d18ec6d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CityProjectFeatures.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -15,7 +16,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest @@ -136,9 +136,8 @@ class CityProjectFeatures { list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", { if (Minecraft.getMinecraft().currentScreen is GuiEditSign) { LorenzUtils.setTextIntoSign("$amount") - } else if (!NEUItems.neuHasFocus() && !LorenzUtils.noTradeMode) { - LorenzUtils.sendCommandToServer("bz ${name.removeColor()}") - OSUtils.copyToClipboard("$amount") + } else { + BazaarApi.searchForBazaarItem(name, amount) } }) { inInventory && !NEUItems.neuHasFocus() }) |