diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-26 18:43:48 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-26 18:43:48 +0100 |
commit | ae4f37412e0e2a522c0a1a77636dac38ea56ff33 (patch) | |
tree | d55935078f8c65461632d87d898d80bec1e55f6e | |
parent | 5e040affe428afbb6bd51be18304cb6e02f9b8a2 (diff) | |
download | skyhanni-ae4f37412e0e2a522c0a1a77636dac38ea56ff33.tar.gz skyhanni-ae4f37412e0e2a522c0a1a77636dac38ea56ff33.tar.bz2 skyhanni-ae4f37412e0e2a522c0a1a77636dac38ea56ff33.zip |
Use duration for time in ServerRestartTitle.
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt | 13 |
1 files changed, 7 insertions, 6 deletions
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) } } |