From ae4f37412e0e2a522c0a1a77636dac38ea56ff33 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:43:48 +0100 Subject: Use duration for time in ServerRestartTitle. --- .../hannibal2/skyhanni/features/misc/ServerRestartTitle.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt index fc83bdfb4..73b003ef6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt @@ -5,9 +5,10 @@ import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -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 +import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds class ServerRestartTitle { @@ -28,11 +29,11 @@ class ServerRestartTitle { for (line in ScoreboardData.sidebarLinesFormatted) { restartPattern.matchMatcher(line) { - val minutes = group("minutes").toInt() - val seconds = group("seconds").toInt() - val totalSeconds = minutes * 60 + seconds - if (totalSeconds > 120 && totalSeconds % 30 != 0) return - val time = TimeUtils.formatDuration(totalSeconds.toLong() * 1000) + val minutes = group("minutes").toInt().minutes + val seconds = group("seconds").toInt().seconds + val totalTime = minutes + seconds + if (totalTime > 2.minutes && totalTime.inWholeSeconds % 30 != 0L) return + val time = totalTime.format() LorenzUtils.sendTitle("§cServer Restart in §b$time", 2.seconds) } } -- cgit