From 357f7493e2cadbe8a543710e71e702874e16df29 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:10:20 +0100 Subject: cleanPlayerName respects playerRankHider option now. --- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 8c75475c9..cb7a0fa23 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -80,7 +81,7 @@ object StringUtils { inline fun Pattern.matchMatcher(text: String, consumer: Matcher.() -> T) = matcher(text).let { if (it.matches()) consumer(it) else null } - fun String.cleanPlayerName(): String { + private fun String.internalCleanPlayerName(): String { val split = trim().split(" ") return if (split.size > 1) { split[1].removeColor() @@ -89,6 +90,16 @@ object StringUtils { } } + fun String.cleanPlayerName(displayName: Boolean = false): String { + return if (displayName) { + if (SkyHanniMod.feature.chat.playerMessage.playerRankHider) { + "§b" + internalCleanPlayerName() + } else this + } else { + internalCleanPlayerName() + } + } + inline fun List.matchMatchers(text: String, consumer: Matcher.() -> T): T? { for (pattern in iterator()) { pattern.matchMatcher(text) { -- cgit