From c9757841e10bb214e8fd7edd0f07e5c5ef88fe4a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 12:48:55 +0100 Subject: Highlight underbid own lowest BIN auctions that are outbid. --- .../features/inventory/AuctionsHighlighter.kt | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt index 453707c5b..f512733b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -3,20 +3,27 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AuctionsHighlighter { + private val config get() = SkyHanniMod.feature.inventory + private val buyItNowPattern by RepoPattern.pattern("auctions.highlight.buyitnow", "§7Buy it now: §6(?.*) coins") @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.inventory.highlightAuctions) return + if (!config.highlightAuctions) return if (event.gui !is GuiChest) return val guiChest = event.gui @@ -31,10 +38,24 @@ class AuctionsHighlighter { val lore = stack.getLore() if (lore.any { it == "§7Status: §aSold!" }) { slot highlight LorenzColor.GREEN + continue } if (lore.any { it == "§7Status: §cExpired!" }) { slot highlight LorenzColor.RED + continue + } + if (config.highlightAuctionsUnderbid) { + for (line in lore) { + buyItNowPattern.matchMatcher(line) { + val coins = group("coins").formatNumber() + stack.getInternalNameOrNull()?.getPriceOrNull()?.let { + if (coins > it) { + slot highlight LorenzColor.GOLD + } + } + } + } } } } -} \ No newline at end of file +} -- cgit