diff options
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 0e2f9af32..37e61257f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -38,6 +38,14 @@ import kotlin.time.Duration.Companion.seconds class HypixelData { private val patternGroup = RepoPattern.group("data.hypixeldata") + private val serverNameConnectionPattern by patternGroup.pattern( + "servername.connection", + "(?<prefix>.+\\.)?hypixel\\.net", + ) + private val serverNameScoreboardPattern by patternGroup.pattern( + "servername.scoreboard", + "§e(?<prefix>.+\\.)?hypixel\\.net", + ) private val islandNamePattern by patternGroup.pattern( "islandname", "(?:§.)*(Area|Dungeon): (?:§.)*(?<island>.*)", @@ -370,12 +378,34 @@ class HypixelData { } private fun checkHypixel() { - val list = ScoreboardData.sidebarLinesFormatted - if (list.isEmpty()) return + val mc = Minecraft.getMinecraft() + val player = mc.thePlayer ?: return + + var hypixel = false + + player.clientBrand?.let { + if (it.contains("hypixel", ignoreCase = true)) { + hypixel = true + } + } + + serverNameConnectionPattern.matchMatcher(mc.getCurrentServerData().serverIP) { + hypixel = true + if (group("prefix") == "alpha.") { + hypixelAlpha = true + } + } + + for (line in ScoreboardData.sidebarLinesFormatted) { + serverNameScoreboardPattern.matchMatcher(line) { + hypixel = true + if (group("prefix") == "alpha.") { + hypixelAlpha = true + } + } + } - val last = list.last() - hypixelLive = last == "§ewww.hypixel.net" - hypixelAlpha = last == "§ealpha.hypixel.net" + hypixelLive = hypixel && !hypixelAlpha } private fun checkSidebar() { |