aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt119
4 files changed, 148 insertions, 0 deletions
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
@@ -87,6 +87,21 @@ public class GUIConfig {
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
@FeatureToggle
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
@@ -199,6 +199,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();
public static class 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(?<time>.+)"
+ )
+ private val boostedStatPattern by group.pattern(
+ "stat",
+ "§7Current Stat: (?<stat>.+)"
+ )
+ private val noBoostedStatPattern by group.pattern(
+ "nostat",
+ "TODO"
+ )
+
+ private var expiryTime: SimpleTimeMark
+ get() = storage?.beaconPowerExpiryTime?.asTimeMark() ?: SimpleTimeMark.farPast()
+ set(value) {
+ storage?.beaconPowerExpiryTime = value.toMillis()
+ }
+
+ private var stat: String?
+ get() = storage?.boostedStat
+ set(value) {
+ storage?.boostedStat = value
+ }
+
+ private var display: String? = null
+
+ private val BEACON_POWER_SLOT = 22
+ private val STATS_SLOT = 23
+
+ @SubscribeEvent
+ fun onInventoryUpdate(event: InventoryUpdatedEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (event.inventoryName != "Beacon") return
+ val items = event.inventoryItems
+
+ items[BEACON_POWER_SLOT]?.let { item ->
+ item.getLore().forEach {
+ if (deactivatedPattern.matches(it)) {
+ expiryTime = SimpleTimeMark.farPast()
+ return@let
+ }
+ timeRemainingPattern.matchMatcher(it) {
+ val duration = TimeUtils.getDuration(group("time"))
+ expiryTime = SimpleTimeMark.now() + duration
+ return@let
+ }
+ }
+ }
+
+ items[STATS_SLOT]?.let { item ->
+ item.getLore().forEach {
+ if (noBoostedStatPattern.matches(it)) {
+ stat = null
+ return@let
+ }
+ boostedStatPattern.matchMatcher(it) {
+ stat = group("stat")
+ return@let
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ if (!isEnabled()) return
+ val string = display ?: return
+ config.beaconPowerPosition.renderString(string, posLabel = "Beacon Power")
+ }
+
+ @SubscribeEvent
+ fun onSecond(event: SecondPassedEvent) {
+ if (!isEnabled()) return
+ display = drawDisplay()
+ }
+
+ private fun drawDisplay(): String {
+ var text = "§eBeacon: "
+ if (expiryTime.isInPast()) text += "§cNot active"
+ else {
+ text += "§b${expiryTime.timeUntil().format(maxUnits = 2)}"
+ if (config.beaconPowerStat) text += " §7(" + (stat ?: "§cNo stat") + "§7)"
+ }
+ return text
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.beaconPower
+}