From f67af16eacb6cdf3598183d473f072d123ef8a25 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sun, 26 May 2024 23:02:48 +1000 Subject: Backend: Convert stuff to SimpleTimeMark (#1777) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/dungeon/DungeonMilestonesDisplay.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/dungeon') diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt index 2e6832eb1..960a8053e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -8,27 +8,29 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent 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.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds object DungeonMilestonesDisplay { private val config get() = SkyHanniMod.feature.dungeon - val milestonePattern by RepoPattern.pattern( + private val milestonePattern by RepoPattern.pattern( "dungeon.milestone", "§e§l.*Milestone §r§e.§r§7: You have (?:tanked and )?(?:dealt|healed) §r§.*§r§7.*so far! §r§a.*" ) private var display = "" private var currentMilestone = 0 - private var timeReached = 0L + private var timeReached = SimpleTimeMark.farPast() var colour = "" @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!event.isMod(5)) return - if (currentMilestone >= 3 && System.currentTimeMillis() > timeReached + 3_000 && display.isNotEmpty()) { + if (currentMilestone >= 3 && timeReached.passedSince() > 3.seconds && display.isNotEmpty()) { display = display.substring(1) } } @@ -47,7 +49,7 @@ object DungeonMilestonesDisplay { private fun update() { if (currentMilestone > 3) return if (currentMilestone == 3) { - timeReached = System.currentTimeMillis() + timeReached = SimpleTimeMark.now() } colour = when (currentMilestone) { -- cgit