From 13c636ff4ad49403c078b208dabd0b87972b0440 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 22 Jun 2023 14:23:26 +0200 Subject: Added rift timer --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../at/hannibal2/skyhanni/config/Features.java | 4 + .../skyhanni/config/features/RiftConfig.java | 37 ++++++++ .../java/at/hannibal2/skyhanni/data/IslandType.kt | 1 + .../hannibal2/skyhanni/features/rift/RiftTimer.kt | 99 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 9 ++ 6 files changed, 152 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 73d136618..cf099e987 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -59,6 +59,7 @@ import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.mobs.MobHighlight import at.hannibal2.skyhanni.features.nether.ashfang.* import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper +import at.hannibal2.skyhanni.features.rift.RiftTimer import at.hannibal2.skyhanni.features.slayer.* import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerClearView import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper @@ -300,6 +301,7 @@ class SkyHanniMod { loadModule(ShowItemUuid()) loadModule(SlayerRngMeterDisplay()) loadModule(GhostCounter) + loadModule(RiftTimer()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index d80195e71..a5a42b48c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -119,6 +119,10 @@ public class Features extends Config { @Category(name = "Ghost Counter", desc = "Ghost Counter settings.") public GhostCounter ghostCounter = new GhostCounter(); + @Expose + @Category(name = "The Rift", desc = "Features for The Rift dimension.") + public RiftConfig rift = new RiftConfig(); + @Expose @Category(name = "Misc", desc = "Settings without a category.") public Misc misc = new Misc(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java new file mode 100644 index 000000000..581413ec0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -0,0 +1,37 @@ +package at.hannibal2.skyhanni.config.features; + +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.Accordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class RiftConfig { + + @ConfigOption(name = "Rift Timer", desc = "") + @Accordion + @Expose + public TimerConfig timer = new TimerConfig(); + + public static class TimerConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show the remaining rift time, max time, percentage, and extra time changes.") + @ConfigEditorBoolean + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Max time", desc = "Show max time.") + @ConfigEditorBoolean + public boolean maxTime = true; + + @Expose + @ConfigOption(name = "Percentage", desc = "Show percentage.") + @ConfigEditorBoolean + public boolean percentage = true; + + @Expose + public Position timerPosition = new Position(10, 10, false, true); + + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 8b9c4dc3e..d3357e880 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -18,6 +18,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { GARDEN("Garden"), GARDEN_GUEST("Garden Guest"), SPIDER_DEN("Spider's Den"), + THE_RIFT("The Rift"), NONE(""), UNKNOWN("???"), diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt new file mode 100644 index 000000000..d1fcc758d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt @@ -0,0 +1,99 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzActionBarEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftTimer { + private val config get() = SkyHanniMod.feature.rift.timer + private var display = listOf() + private var maxTime = 0L + private var latestTime = 0L + private val changes = mutableMapOf() + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + display = emptyList() + } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!isEnabled()) return + + val message = event.message + " §r§7You have §r§a(?