From c03d6b26f0d5a8e1d99b5e8f49de0d3aa87969a9 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 23 Mar 2024 17:12:12 +0100 Subject: Backend: Fixed usage of checkCurrentServerId() (#1177) --- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 18 +++++++++++------- .../features/mining/eventtracker/MiningEventTracker.kt | 12 +----------- 2 files changed, 12 insertions(+), 18 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index eb38187ca..9eb2aa5e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -117,26 +117,30 @@ class HypixelData { val mode get() = locraw["mode"] ?: "" val map get() = locraw["map"] ?: "" - fun getCurrentServerId(): String? { - if (!LorenzUtils.inSkyBlock) return null - if (serverId != null) return serverId + fun checkCurrentServerId() { + if (!LorenzUtils.inSkyBlock) return ScoreboardData.sidebarLinesFormatted.forEach { serverIdScoreboardPattern.matchMatcher(it) { val serverType = if (group("servertype") == "M") "mega" else "mini" serverId = "$serverType${group("serverid")}" - return serverId + return } } TabListData.getTabList().forEach { serverIdTablistPattern.matchMatcher(it) { serverId = group("serverid") - return serverId + return } } - return serverId + ErrorManager.logErrorWithData( + Exception("NoServerId"), "Could not find server id", + "islandType" to LorenzUtils.skyBlockIsland, + "tablist" to TabListData.getTabList(), + "scoreboard" to ScoreboardData.sidebarLinesFormatted + ) } fun getPlayersOnCurrentServer(): Int { @@ -303,7 +307,7 @@ class HypixelData { if (inSkyBlock) { checkIsland() checkSidebar() - getCurrentServerId() + checkCurrentServerId() } if (inSkyBlock == skyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt index 019104aa8..4d4b59b6f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.data.BossbarData import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.BossbarUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent @@ -16,7 +15,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.fromJson import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -125,15 +123,7 @@ class MiningEventTracker { } eventEndTime = SimpleTimeMark.now() + timeRemaining - val serverId = HypixelData.getCurrentServerId() ?: run { - ErrorManager.logErrorWithData( - Exception("NoServerId"), "Could not find server id", - "islandType" to LorenzUtils.skyBlockIsland, - "tablist" to TabListData.getTabList(), - "scoreboard" to ScoreboardData.sidebarLinesFormatted - ) - return - } + val serverId = HypixelData.serverId ?: return val miningEventData = MiningEventDataSend( LorenzUtils.skyBlockIsland, -- cgit