From 4c6da9bb41db05c08de564b47bbe52b93db71eb4 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Sat, 22 Apr 2023 13:36:38 +0200 Subject: Fix getting location from scoreboard (#678) --- .../moulberry/notenoughupdates/util/SidebarUtil.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SidebarUtil.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SidebarUtil.kt index ad371b56..503085f0 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SidebarUtil.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SidebarUtil.kt @@ -24,18 +24,17 @@ import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam object SidebarUtil { - @JvmStatic - fun readSidebarLines() = readRawSidebarLines(true) + @JvmOverloads + fun readSidebarLines(cleanColor: Boolean = true, cleanSpecialCharacters: Boolean = true): List { + var result = readRawSidebarLines() + if (cleanColor) result = result.map { Utils.cleanColour(it) } + if (cleanSpecialCharacters) result.map { cleanSB(it) } + return result + } @JvmStatic - fun readRawSidebarLines(cleanColor: Boolean = false): List { - val list = fetchScoreboardLines().reversed() - val result = list.map { cleanSB(it) } - return if (cleanColor) { - result.map { Utils.cleanColour(it) } - } else result - } + fun readRawSidebarLines() = fetchScoreboardLines().reversed() private fun cleanSB(scoreboard: String) = scoreboard.toCharArray().filter { it.code in 21..126 || it.code == 167 }.joinToString(separator = "") -- cgit