diff options
author | Luna <luna@alexia.lol> | 2024-06-12 17:51:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-12 17:51:13 +0200 |
commit | c2a3de433b5a169c7a4dcb138247457d09ad1d45 (patch) | |
tree | 2a31f5a5ddbbacfa210c8ac14b0f1f984276c70b /src/main | |
parent | 3d221e4be8c03f6ad480d33093923d778d9f1eb0 (diff) | |
download | skyhanni-c2a3de433b5a169c7a4dcb138247457d09ad1d45.tar.gz skyhanni-c2a3de433b5a169c7a4dcb138247457d09ad1d45.tar.bz2 skyhanni-c2a3de433b5a169c7a4dcb138247457d09ad1d45.zip |
Improvement: Better Hypixel detection (#2064)
Diffstat (limited to 'src/main')
-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() { |