From aa9bbeaf75c571b88f02874f480da04f8424d78d Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:08:46 +0200 Subject: Improvement: Use SkyblockArea.skyblockAreaWithSymbol for Custom Scoreboard Area (#1350) --- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 25 ++++++++++++++++------ .../gui/customscoreboard/ScoreboardElements.kt | 7 +----- .../skyhanni/utils/repopatterns/RepoPattern.kt | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 3ea3a9008..fe5ca67b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -84,6 +84,15 @@ class HypixelData { "SK[YI]BLOCK(?: CO-OP| GUEST)?" ) + /** + * REGEX-TEST: §7⏣ §bVillage + * REGEX-TEST: §5ф §dWizard Tower + */ + private val skyblockAreaPattern by patternGroup.pattern( + "skyblock.area", + "\\s*§(?7⏣|5ф) §(?.)(?.*)" + ) + var hypixelLive = false var hypixelAlpha = false var inLobby = false @@ -103,6 +112,7 @@ class HypixelData { var joinedWorld = SimpleTimeMark.farPast() var skyBlockArea = "?" + var skyBlockAreaWithSymbol = "?" // Data from locraw var locrawData: JsonObject? = null @@ -155,7 +165,7 @@ class HypixelData { playerAmountGuestingPattern ) - out@for (pattern in playerPatternList) { + out@ for (pattern in playerPatternList) { for (line in TabListData.getTabList()) { pattern.matchMatcher(line) { amount += group("amount").toInt() @@ -282,11 +292,14 @@ class HypixelData { } if (LorenzUtils.inSkyBlock) { - val originalLocation = ScoreboardData.sidebarLinesFormatted - .firstOrNull { it.startsWith(" §7⏣ ") || it.startsWith(" §5ф ") } - ?.substring(5)?.removeColor() - ?: "?" - skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation + loop@ for (line in ScoreboardData.sidebarLinesFormatted) { + skyblockAreaPattern.matchMatcher(line) { + val originalLocation = group("area") + skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation + skyBlockAreaWithSymbol = line.trim() + break@loop + } + } checkProfileName() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index d3e3b6c1c..65d8d880c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -482,13 +482,8 @@ private fun getEmptyLineDisplayPair() = listOf("" to HorizontalAlignment. private fun getIslandDisplayPair() = listOf("§7㋖ §a" + HypixelData.skyBlockIsland.displayName to HorizontalAlignment.LEFT) -// TODO merge with LorenzUtils.skyBlockArea private fun getLocationDisplayPair() = buildList { - val location = - getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.locationPattern, "location").trim() - if (location == "0") return@buildList - - add(location to HorizontalAlignment.LEFT) + add(HypixelData.skyBlockAreaWithSymbol to HorizontalAlignment.LEFT) ScoreboardData.sidebarLinesFormatted.firstOrNull { ScoreboardPattern.plotPattern.matches(it) } ?.let { add(it to HorizontalAlignment.LEFT) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt index 2e1259343..d04384ba0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt @@ -63,7 +63,7 @@ interface RepoPattern : ReadOnlyProperty { val defaultPattern: String /** - * Key for this pattern. Used as an identifier when loading from the repo. Should be consistent accross versions. + * Key for this pattern. Used as an identifier when loading from the repo. Should be consistent across versions. */ val key: String -- cgit