diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-10-06 21:58:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-06 21:58:51 +0200 |
commit | 41d59a6888a8e1132e57dfab279efa8426853970 (patch) | |
tree | f45a9e819c48ca3e181d3e07633535f02962d195 /src | |
parent | cbaae605593df9ce1edf1675f0ef6d4e560fc6ff (diff) | |
download | skyhanni-41d59a6888a8e1132e57dfab279efa8426853970.tar.gz skyhanni-41d59a6888a8e1132e57dfab279efa8426853970.tar.bz2 skyhanni-41d59a6888a8e1132e57dfab279efa8426853970.zip |
Improvement: Fewer Server id errors (#2680)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 039bd7d28..f34dafb3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigManager.Companion.gson import at.hannibal2.skyhanni.data.model.TabWidget +import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -119,6 +120,9 @@ object HypixelData { var skyBlock = false var skyBlockIsland = IslandType.UNKNOWN var serverId: String? = null + private var lastSuccessfulServerIdFetchTime = SimpleTimeMark.farPast() + private var lastSuccessfulServerIdFetchType: String? = null + private var failedServerIdFetchCounter = 0 // Ironman, Stranded and Bingo var noTrade = false @@ -159,24 +163,56 @@ object HypixelData { TabWidget.SERVER.matchMatcherFirstLine { serverId = group("serverid") + lastSuccessfulServerIdFetchTime = SimpleTimeMark.now() + lastSuccessfulServerIdFetchType = "tab list" + failedServerIdFetchCounter = 0 return } ScoreboardData.sidebarLinesFormatted.matchFirst(serverIdScoreboardPattern) { val serverType = if (group("servertype") == "M") "mega" else "mini" serverId = "$serverType${group("serverid")}" + lastSuccessfulServerIdFetchTime = SimpleTimeMark.now() + lastSuccessfulServerIdFetchType = "scoreboard" + failedServerIdFetchCounter = 0 return } + failedServerIdFetchCounter++ + if (failedServerIdFetchCounter < 3) return ErrorManager.logErrorWithData( Exception("NoServerId"), "Could not find server id", + "failedServerIdFetchCounter" to failedServerIdFetchCounter, + "lastSuccessfulServerIdFetchTime" to lastSuccessfulServerIdFetchTime, + "lastSuccessfulServerIdFetchType" to lastSuccessfulServerIdFetchType, "islandType" to LorenzUtils.skyBlockIsland, "tablist" to TabListData.getTabList(), "scoreboard" to ScoreboardData.sidebarLinesFormatted, ) } + @SubscribeEvent + fun onDebugDataCollect(event: DebugDataCollectEvent) { + event.title("Server ID") + val id = serverId + if (id == null) { + event.addData { + add("server id is null!") + add("failedServerIdFetchCounter: $failedServerIdFetchCounter") + add("") + add("last successful fetch time: $lastSuccessfulServerIdFetchTime") + add("last successful fetch type: $lastSuccessfulServerIdFetchType") + } + } else { + event.addIrrelevant { + add("Server id: '$id'") + add("fetch time: $lastSuccessfulServerIdFetchTime") + add("fetch type: $lastSuccessfulServerIdFetchType") + } + } + } + fun getPlayersOnCurrentServer(): Int { var amount = 0 val playerPatternList = mutableListOf( |