diff options
Diffstat (limited to 'src/main/kotlin/cc/woverflow')
4 files changed, 33 insertions, 7 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 diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt index 99a8999..cdec672 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt @@ -45,26 +45,37 @@ object ChatTabs { applyVersion2Changes(it.asJsonObject) applyVersion3Changes(it.asJsonObject) applyVersion4Changes(it.asJsonObject) + applyVersion5Changes(it.asJsonObject) } chatTabJson.version = ChatTabsJson.VERSION - tabFile.writeText(chatTabJson.toString()) + tabFile.writeText(GSON.toJson(chatTabJson)) } 2 -> { // ver 3 adds ignore_ chatTabJson.tabs.forEach { applyVersion3Changes(it.asJsonObject) applyVersion4Changes(it.asJsonObject) + applyVersion5Changes(it.asJsonObject) } chatTabJson.version = ChatTabsJson.VERSION - tabFile.writeText(chatTabJson.toString()) + tabFile.writeText(GSON.toJson(chatTabJson)) } 3 -> { // ver 4 adds color options chatTabJson.tabs.forEach { applyVersion4Changes(it.asJsonObject) + applyVersion5Changes(it.asJsonObject) } chatTabJson.version = ChatTabsJson.VERSION - tabFile.writeText(chatTabJson.toString()) + tabFile.writeText(GSON.toJson(chatTabJson)) + } + 4 -> { + // ver 5 adds lowercase + chatTabJson.tabs.forEach { + applyVersion5Changes(it.asJsonObject) + } + chatTabJson.version = ChatTabsJson.VERSION + tabFile.writeText(GSON.toJson(chatTabJson)) } } chatTabJson.tabs.forEach { @@ -103,6 +114,10 @@ object ChatTabs { json.addProperty("selected_color", TabButton.selectedColor) } + private fun applyVersion5Changes(json: JsonObject) { + json.addProperty("lowercase", false) + } + fun shouldRender(message: IChatComponent): Boolean { return currentTab?.shouldRender(message) ?: true } @@ -113,7 +128,7 @@ object ChatTabs { val defaultTabs = generateDefaultTabs() jsonObject.add("tabs", defaultTabs) jsonObject.addProperty("version", ChatTabsJson.VERSION) - tabFile.writeText(jsonObject.toString()) + tabFile.writeText(GSON.toJson(jsonObject)) } private fun generateDefaultTabs(): JsonArray { @@ -121,6 +136,7 @@ object ChatTabs { true, "ALL", false, + false, null, null, null, @@ -140,6 +156,7 @@ object ChatTabs { true, "PARTY", false, + false, listOf("§r§9Party §8> ", "§r§9P §8> ", "§eThe party was transferred to §r", "§eKicked §r"), null, listOf( @@ -208,6 +225,7 @@ object ChatTabs { true, "GUILD", true, + false, listOf("Guild >", "G >"), null, null, @@ -227,6 +245,7 @@ object ChatTabs { true, "PM", true, + false, listOf("To ", "From "), null, null, diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabsJson.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabsJson.kt index 6954b8e..b239bbd 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabsJson.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabsJson.kt @@ -10,6 +10,6 @@ data class ChatTabsJson(@SerializedName("tabs") val tabs: JsonArray, var version } companion object { - const val VERSION = 4 + const val VERSION = 5 } }
\ No newline at end of file diff --git a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt index ae2187f..93a8723 100644 --- a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt +++ b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt @@ -183,6 +183,7 @@ object ChattingConfig : true, "ALL", false, + false, null, null, null, |