diff options
author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-04-04 21:08:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 21:08:46 +0200 |
commit | aa9bbeaf75c571b88f02874f480da04f8424d78d (patch) | |
tree | 8f99fcef41f71b16a8370ffb2d617207bde33e97 | |
parent | 15db91ced38a8cc4c7c16565422fce5566c6057c (diff) | |
download | skyhanni-aa9bbeaf75c571b88f02874f480da04f8424d78d.tar.gz skyhanni-aa9bbeaf75c571b88f02874f480da04f8424d78d.tar.bz2 skyhanni-aa9bbeaf75c571b88f02874f480da04f8424d78d.zip |
Improvement: Use SkyblockArea.skyblockAreaWithSymbol for Custom Scoreboard Area (#1350)
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*§(?<symbol>7⏣|5ф) §(?<color>.)(?<area>.*)" + ) + 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("<empty>" 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<Any?, Pattern> { 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 |