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 | |
parent | b8aa42e5564714a4fbf611ccae42ed3b6905405c (diff) | |
download | Chatting-04363f543d136bd43f82d28ff569ae4522fba37a.tar.gz Chatting-04363f543d136bd43f82d28ff569ae4522fba37a.tar.bz2 Chatting-04363f543d136bd43f82d28ff569ae4522fba37a.zip |
make prefix property not required
add lowercase property
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | docs/chattabs.md | 22 | ||||
-rw-r--r-- | settings.gradle | 7 | ||||
-rw-r--r-- | src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java | 2 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt | 10 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt | 27 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/chat/ChatTabsJson.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt | 1 |
8 files changed, 50 insertions, 23 deletions
diff --git a/build.gradle b/build.gradle index 430a98a..e4b3b7f 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ plugins { } version = mod_version -group = "com.example" +group = "cc.woverflow" archivesBaseName = mod_name blossom { diff --git a/docs/chattabs.md b/docs/chattabs.md index 0738310..8c27d17 100644 --- a/docs/chattabs.md +++ b/docs/chattabs.md @@ -12,15 +12,16 @@ something like this: "enabled": true, "name": "ALL", "unformatted": false, + "lowercase": false, "color": 14737632, "hovered_color": 16777120, - "selected_color": 10526880, - "prefix": "" + "selected_color": 10526880 }, { "enabled": true, "name": "PARTY", "unformatted": false, + "lowercase": false, "starts": [ "§r§9Party §8> ", "§r§9P §8> ", @@ -90,6 +91,7 @@ something like this: "enabled": true, "name": "GUILD", "unformatted": true, + "lowercase": false, "starts": [ "Guild >", "G >" @@ -103,6 +105,7 @@ something like this: "enabled": true, "name": "PM", "unformatted": true, + "lowercase": false, "starts": [ "To ", "From " @@ -113,7 +116,7 @@ something like this: "prefix": "/r " } ], - "version": 4 + "version": 5 } ``` @@ -222,17 +225,22 @@ The `selected_color` property allows you to change the color of the chat tab tex over all the other color properties. Like the other color properties, it is in RGBA format. The `prefix` property appends the prefix to any message sent while in the specific chat tab **if it is not a command**. -This can be used to automatically send messages in a specific channel in servers, like in Hypixel. +This can be used to automatically send messages in a specific channel in servers, like in Hypixel. This is no longer required as of version 5. + +The `lowercase` property makes the message trigger lowercase. ## Chat Tabs JSON Changelogs +### Version 5 (Chatting 1.4.0) +- The `prefix` property is no longer a required property. +- Added `lowercase` property -### Version 4 +### Version 4 (Chatting 1.4.0 [eece3cb]) - Added color text options (`color`, `hovered_color`, and `selected_color`) - `version` is now actually an integer -### Version 3 +### Version 3 (Chatting 1.4.0-alpha1) - Added `ignore_` options (`ignore_starts`, `ignore_ends`, `ignore_equals`, and `ignore_regex`) -### Version 2 +### Version 2 (1.0.0) - Added `enabled` property
\ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 6b018a3..4f8d00d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,13 +3,6 @@ pluginManagement { gradlePluginPortal() maven { url = "https://repo.woverflow.cc" } } - resolutionStrategy { - eachPlugin { - if (requested.id.id == "cc.woverflow.loom") { - useModule("cc.woverflow:architectury-loom:${requested.version}") - } - } - } } rootProject.name = mod_name
\ No newline at end of file diff --git a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java index 42c5579..2c19b0f 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java @@ -12,7 +12,7 @@ public class EntityPlayerSPMixin { @ModifyVariable(method = "sendChatMessage", at = @At("HEAD"), ordinal = 0, argsOnly = true) private String handleSentMessages(String value) { if (value.startsWith("/")) return value; - if (ChattingConfig.INSTANCE.getChatTabs() && ChatTabs.INSTANCE.getCurrentTab() != null && !ChatTabs.INSTANCE.getCurrentTab().getPrefix().isEmpty()) { + if (ChattingConfig.INSTANCE.getChatTabs() && ChatTabs.INSTANCE.getCurrentTab() != null && ChatTabs.INSTANCE.getCurrentTab().getPrefix() != null && !ChatTabs.INSTANCE.getCurrentTab().getPrefix().isEmpty()) { return ChatTabs.INSTANCE.getCurrentTab().getPrefix() + value; } else { return value; 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, |