From a7372158d4e75d7f32f0cbf607940499e767dbe5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 15:53:53 +0100 Subject: Added Auction Highlighter. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../skyhanni/config/features/Inventory.java | 6 ++++ .../skyhanni/features/bazaar/BazaarOrderHelper.kt | 3 ++ .../features/inventory/AuctionsHighlighter.kt | 36 ++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index c07feba3b..78644dad0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -116,6 +116,7 @@ public class SkyHanniMod { //features loadModule(new BazaarOrderHelper()); + loadModule(new AuctionsHighlighter()); loadModule(new ChatFilter()); loadModule(new PlayerChatModifier()); loadModule(new DungeonChatFilter()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index f4df59580..912e09531 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -137,4 +137,10 @@ public class Inventory { desc = "Highlight stuff that is missing in the skyblock level guide inventory.") @ConfigEditorBoolean public boolean highlightMissingSkyBlockLevelGuide = true; + + @Expose + @ConfigOption(name = "Highlight Auctions", + desc = "Highlight own items that are sold in green.") + @ConfigEditorBoolean + public boolean highlightAuctions = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt index 7f0e86598..bd9ef0a79 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName 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.RenderUtils.highlight import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -23,8 +24,10 @@ class BazaarOrderHelper { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.bazaar.orderHelper) return if (event.gui !is GuiChest) return + val guiChest = event.gui val chest = guiChest.inventorySlots as ContainerChest val inventoryName = chest.getInventoryName() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt new file mode 100644 index 000000000..ba1d3a680 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -0,0 +1,36 @@ +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.getLore +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class AuctionsHighlighter { + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.inventory.highlightAuctions) return + if (event.gui !is GuiChest) return + + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + if (chest.getInventoryName() != "Manage Auctions") return + + for (slot in chest.inventorySlots) { + if (slot == null) continue + if (slot.slotNumber != slot.slotIndex) continue + val stack = slot.stack ?: continue + + if (stack.getLore().any { it == "§7Status: §aSold!" }) { + slot highlight LorenzColor.GREEN + } + } + } +} \ No newline at end of file -- cgit