diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-11 11:59:13 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-11 11:59:13 +0100 |
commit | 389e74e1554baa30b48c56ef88235f09df031e6d (patch) | |
tree | abf0bd15aa8189903df818d3c96eaff70bcfe862 /src/main/java/at | |
parent | ec48346c3a886f7631adeb0735772885d66747e2 (diff) | |
download | skyhanni-389e74e1554baa30b48c56ef88235f09df031e6d.tar.gz skyhanni-389e74e1554baa30b48c56ef88235f09df031e6d.tar.bz2 skyhanni-389e74e1554baa30b48c56ef88235f09df031e6d.zip |
Added Power Stone Guide features
Diffstat (limited to 'src/main/java/at')
3 files changed, 87 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index de7d08e86..93e84a6d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -204,6 +204,7 @@ import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems import at.hannibal2.skyhanni.features.inventory.HighlightBonzoMasks import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures import at.hannibal2.skyhanni.features.inventory.ItemStars +import at.hannibal2.skyhanni.features.inventory.PowerStoneGuideFeatures import at.hannibal2.skyhanni.features.inventory.QuickCraftFeatures import at.hannibal2.skyhanni.features.inventory.RngMeterInventory import at.hannibal2.skyhanni.features.inventory.SackDisplay @@ -532,6 +533,7 @@ class SkyHanniMod { loadModule(CrimsonIsleReputationHelper(this)) loadModule(SharkFishCounter()) loadModule(SkyBlockLevelGuideHelper()) + loadModule(PowerStoneGuideFeatures()) loadModule(OdgerWaypoint()) loadModule(TiaRelayHelper()) loadModule(TiaRelayWaypoints()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 80ee50233..48be602a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -156,6 +156,13 @@ public class InventoryConfig { public boolean highlightMissingSkyBlockLevelGuide = true; @Expose + @ConfigOption(name = "Power Stone Guide", + desc = "Highlight missing power stones, show their total bazaar price, and allows to open the bazaar when clicking on the items in the Power Stone Guide.") + @ConfigEditorBoolean + @FeatureToggle + public boolean powerStoneGuide = true; + + @Expose @ConfigOption(name = "Highlight Auctions", desc = "Highlight own items that are sold in green and that are expired in red.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt new file mode 100644 index 000000000..24972cde5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt @@ -0,0 +1,78 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.utils.ItemUtils.getItemName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.nextAfter +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getPrice +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class PowerStoneGuideFeatures { + + private var missing = mutableMapOf<Int, NEUInternalName>() + private var inInventory = false + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!isEnabled()) return + if (event.inventoryName != "Power Stones Guide") return + + inInventory = true + + for ((slot, item) in event.inventoryItems) { + val lore = item.getLore() + if (lore.contains("§7Learned: §cNot Yet ✖")) { + val rawName = lore.nextAfter("§7Power stone:") ?: continue + val name = NEUInternalName.fromItemName(rawName) + missing[slot] = name + } + } + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + } + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!isEnabled()) return + if (!inInventory) return + + event.gui.inventorySlots.inventorySlots + .filter { missing.containsKey(it.slotNumber) } + .forEach { it highlight LorenzColor.RED } + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!isEnabled()) return + if (!inInventory) return + val internalName = missing[event.slotId] ?: return + + BazaarApi.searchForBazaarItem(internalName.getItemName(), 9) + } + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + if (!isEnabled()) return + if (!inInventory) return + + val internalName = missing[event.slot.slotNumber] ?: return + val totalPrice = internalName.getPrice() * 9 + event.toolTip.add(5, "9x from Bazaar: §6${NumberUtil.format(totalPrice)}") + } + + fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.inventory.powerStoneGuide + +} |