From 04363f543d136bd43f82d28ff569ae4522fba37a Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sun, 1 May 2022 08:42:43 +0700 Subject: make prefix property not required add lowercase property --- src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt') diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt index 2cd4418..50de1f4 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt @@ -5,11 +5,13 @@ import com.google.gson.annotations.SerializedName import net.minecraft.client.Minecraft import net.minecraft.util.EnumChatFormatting import net.minecraft.util.IChatComponent +import java.util.* data class ChatTab( val enabled: Boolean, val name: String, val unformatted: Boolean, + val lowercase: Boolean?, @SerializedName("starts") val startsWith: List?, val contains: List?, @SerializedName("ends") val endsWith: List?, @@ -23,7 +25,7 @@ data class ChatTab( val color: Int?, @SerializedName("hovered_color") val hoveredColor: Int?, @SerializedName("selected_color") val selectedColor: Int?, - val prefix: String, + val prefix: String?, ) { lateinit var button: TabButton lateinit var compiledRegex: ChatRegexes @@ -43,7 +45,11 @@ data class ChatTab( fun shouldRender(chatComponent: IChatComponent): Boolean { val message = - if (unformatted) EnumChatFormatting.getTextWithoutFormattingCodes(chatComponent.unformattedText) else chatComponent.formattedText + (if (unformatted) EnumChatFormatting.getTextWithoutFormattingCodes(chatComponent.unformattedText) else chatComponent.formattedText).let { + if (lowercase == true) it.lowercase( + Locale.ENGLISH + ) else it + } ignoreStartsWith?.forEach { if (message.startsWith(it)) { return false -- cgit