From 4a6e2b16fc0171124c2a900751a34f71c5e470cd Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:13:37 +0200 Subject: Feature: Beacon Power Display (#1901) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../skyhanni/config/features/gui/GUIConfig.java | 15 +++ .../config/storage/ProfileSpecificStorage.java | 12 +++ .../hannibal2/skyhanni/features/gui/BeaconPower.kt | 119 +++++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 6fd2154e8..d56b17d73 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -252,6 +252,7 @@ import at.hannibal2.skyhanni.features.garden.visitor.NPCVisitorFix import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener import at.hannibal2.skyhanni.features.garden.visitor.VisitorRewardWarning +import at.hannibal2.skyhanni.features.gui.BeaconPower import at.hannibal2.skyhanni.features.gui.MovableHotBar import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern @@ -936,6 +937,7 @@ class SkyHanniMod { loadModule(PestFinder) loadModule(PestParticleWaypoint()) loadModule(StereoHarmonyDisplay()) + loadModule(BeaconPower()) loadModule(PestParticleLine()) loadModule(SprayFeatures()) loadModule(DojoRankDisplay()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java index b259fd26d..a242d099f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java @@ -86,6 +86,21 @@ public class GUIConfig { @Accordion public InGameDateConfig inGameDate = new InGameDateConfig(); + @Expose + @ConfigOption(name = "Beacon Power", desc = "Displays the current beacon power duration and what stat is boosted.") + @ConfigEditorBoolean + @FeatureToggle + public boolean beaconPower = false; + + @Expose + @ConfigOption(name = "Show Beacon Stat", desc = "Show what stat is being boosted by your beacon.") + @ConfigEditorBoolean + public boolean beaconPowerStat = true; + + @Expose + @ConfigLink(owner = GUIConfig.class, field = "beaconPower") + public Position beaconPowerPosition = new Position(10, 10); + @Expose @ConfigOption(name = "Real Time", desc = "Display the current computer time, a handy feature when playing in full-screen mode.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index d73e707ab..d88ccb315 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -198,6 +198,18 @@ public class ProfileSpecificStorage { } } + @Expose + public BeaconPowerStorage beaconPower = new BeaconPowerStorage(); + + public static class BeaconPowerStorage { + + @Expose + public Long beaconPowerExpiryTime = null; + + @Expose + public String boostedStat = null; + } + @Expose public CrimsonIsleStorage crimsonIsle = new CrimsonIsleStorage(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt new file mode 100644 index 000000000..04ab13333 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt @@ -0,0 +1,119 @@ +package at.hannibal2.skyhanni.features.gui + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class BeaconPower { + + private val storage get() = ProfileStorageData.profileSpecific?.beaconPower + private val config get() = SkyHanniMod.feature.gui + + private val group = RepoPattern.group("gui.beaconpower") + + private val deactivatedPattern by group.pattern( + "deactivated", + "§7Beacon Deactivated §8- §cNo Power Remaining" + ) + private val timeRemainingPattern by group.pattern( + "time", + "§7Power Remaining: §e(?