diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-01 08:42:43 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-01 08:42:43 +0700 |
commit | 04363f543d136bd43f82d28ff569ae4522fba37a (patch) | |
tree | feb98ee80beb8c143310634c3e57f5e8b013d94a /src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt | |
parent | b8aa42e5564714a4fbf611ccae42ed3b6905405c (diff) | |
download | Chatting-04363f543d136bd43f82d28ff569ae4522fba37a.tar.gz Chatting-04363f543d136bd43f82d28ff569ae4522fba37a.tar.bz2 Chatting-04363f543d136bd43f82d28ff569ae4522fba37a.zip |
make prefix property not required
add lowercase property
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt')
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt | 10 |
1 files changed, 8 insertions, 2 deletions
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<String>?, val contains: List<String>?, @SerializedName("ends") val endsWith: List<String>?, @@ -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 |