aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-01 08:42:43 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-01 08:42:43 +0700
commit04363f543d136bd43f82d28ff569ae4522fba37a (patch)
treefeb98ee80beb8c143310634c3e57f5e8b013d94a /src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
parentb8aa42e5564714a4fbf611ccae42ed3b6905405c (diff)
downloadChatting-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/ChatTabs.kt')
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt27
1 files changed, 23 insertions, 4 deletions
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,