From 0c510cb4e246897d53b98589ffe3f690127df625 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Mar 2023 16:26:46 +0100 Subject: Fixed check if on barn plot. --- src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt | 4 ++-- .../java/at/hannibal2/skyhanni/data/ScoreboardData.kt | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt index 9d620f565..2893e67a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt @@ -29,7 +29,7 @@ class HyPixelData { var profile = "" fun readSkyBlockArea(): String { - return ScoreboardData.sidebarLinesFormatted() + return ScoreboardData.sidebarLinesFormatted .firstOrNull { it.startsWith(" §7⏣ ") } ?.substring(5)?.removeColor() ?: "invalid" @@ -101,7 +101,7 @@ class HyPixelData { stranded = false bingo = false - for (line in ScoreboardData.sidebarLinesFormatted()) { + for (line in ScoreboardData.sidebarLinesFormatted) { when (line) { " §7Ⓑ §7Bingo", // No Rank " §bⒷ §bBingo", // Rank 1 diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 91cef39a9..6da73b554 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam @@ -28,9 +27,9 @@ class ScoreboardData { "\uD83C\uDF82", ) - fun sidebarLinesFormatted(): List { + fun formatLines(rawList: List): List { val list = mutableListOf() - for (line in sidebarLinesRaw) { + for (line in rawList) { val seperator = splitIcons.find { line.contains(it) } ?: continue val split = line.split(seperator) val start = split[0] @@ -46,6 +45,9 @@ class ScoreboardData { return list } + var sidebarLinesFormatted: List = emptyList() + + // TODO remove these two var sidebarLines: List = emptyList() var sidebarLinesRaw: List = emptyList() } @@ -54,13 +56,14 @@ class ScoreboardData { fun onTick(event: TickEvent.ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return - val list = fetchScoreboardLines() - sidebarLines = list.map { cleanSB(it) }.reversed() - sidebarLinesRaw = list.reversed() + val list = fetchScoreboardLines().reversed() + sidebarLines = list.map { cleanSB(it) } + sidebarLinesRaw = list + sidebarLinesFormatted = formatLines(list) } private fun cleanSB(scoreboard: String): String { - return scoreboard.removeColor().toCharArray().filter { it.code in 21..126 }.joinToString(separator = "") + return scoreboard.toCharArray().filter { it.code in 21..126 || it.code == 167 }.joinToString(separator = "") } fun fetchScoreboardLines(): List { -- cgit