diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-26 18:47:45 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-26 18:47:45 +0100 |
commit | 7b84d0094777fdd931b56fc34467973b60fea1f6 (patch) | |
tree | e86d846f43951729dc5e2115683b7bde34238015 | |
parent | ae4f37412e0e2a522c0a1a77636dac38ea56ff33 (diff) | |
download | skyhanni-7b84d0094777fdd931b56fc34467973b60fea1f6.tar.gz skyhanni-7b84d0094777fdd931b56fc34467973b60fea1f6.tar.bz2 skyhanni-7b84d0094777fdd931b56fc34467973b60fea1f6.zip |
Added error handling for ServerRestartTitle problems.
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt | 21 |
1 files changed, 15 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 73b003ef6..34196acbe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUtils.format @@ -29,12 +30,20 @@ class ServerRestartTitle { for (line in ScoreboardData.sidebarLinesFormatted) { restartPattern.matchMatcher(line) { - 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) + try { + 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) + } catch (e: Throwable) { + ErrorManager.logErrorWithData( + e, "Error reading server restart time from socreboard", + "line" to line, + "restartPattern" to restartPattern.pattern(), + ) + } } } } |