From dd2a77f37504f81e09806e1c277451957ea455ac Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:26:49 +0100 Subject: fishing profit tracker (#703) Fishing Tracker #703 --- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index dd114d8fd..d5365703a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -36,14 +36,18 @@ object StringUtils { return first + lowercase.substring(1) } - fun String.removeColor(): String { + private val formattingChars by lazy { "kmolnr".toCharArray() + "kmolnr".uppercase().toCharArray() } + + fun String.removeColor(keepFormatting: Boolean = false): String { val builder = StringBuilder(this.length) var counter = 0 while (counter < this.length) { if (this[counter] == 'ยง') { - counter += 2 - continue + if (!keepFormatting || this[counter + 1] !in formattingChars) { + counter += 2 + continue + } } builder.append(this[counter]) counter++ @@ -132,7 +136,6 @@ object StringUtils { } } - fun String.removeWordsAtEnd(i: Int) = split(" ").dropLast(i).joinToString(" ") fun String.splitLines(width: Int): String { -- cgit