aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2021-12-26 13:05:36 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2021-12-26 13:05:36 +0700
commit913ab61c3637833e445669ad252a72b9d6e5947d (patch)
tree7cfe2353406530fc510ae1ac490216dec8b2c0d6 /src
parent8f8d8e2dbe795309b69162bc3760dd4789fc6b73 (diff)
downloadChatting-913ab61c3637833e445669ad252a72b9d6e5947d.tar.gz
Chatting-913ab61c3637833e445669ad252a72b9d6e5947d.tar.bz2
Chatting-913ab61c3637833e445669ad252a72b9d6e5947d.zip
enabled (real)
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt2
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt1
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt18
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt7
4 files changed, 24 insertions, 4 deletions
diff --git a/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt b/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
index ecc0c09..8600416 100644
--- a/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
+++ b/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
@@ -123,7 +123,7 @@ object StratusConfig : Vigilant(File(Stratus.modDir, "${Stratus.ID}.toml"), Stra
chatTabs = funny
ChatTabs.initialize()
if (!funny) {
- val dummy = ChatTab("ALL", false, null, null, null, null, null, "")
+ val dummy = ChatTab(true, "ALL", false, null, null, null, null, null, "")
dummy.initialize()
ChatTabs.currentTab = dummy
} else {
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt b/src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt
index 2f3a729..fa56a54 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt
+++ b/src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt
@@ -7,6 +7,7 @@ import net.minecraft.util.EnumChatFormatting
import net.minecraft.util.IChatComponent
data class ChatTab(
+ val enabled: Boolean,
val name: String,
val unformatted: Boolean,
@SerializedName("starts") val startsWith: List<String>?,
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt b/src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt
index a994f3d..8d03ed6 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt
+++ b/src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt
@@ -34,8 +34,19 @@ object ChatTabs {
} else {
try {
val chatTabJson = GSON.fromJson(tabFile.readText(), ChatTabsJson::class.java)
+ if (chatTabJson.version == 1) {
+ // ver 2 adds `enabled`
+ chatTabJson.tabs.forEach {
+ it.asJsonObject.addProperty("enabled", true)
+ }
+ chatTabJson.version = 2
+ tabFile.writeText(chatTabJson.toString())
+ }
chatTabJson.tabs.forEach {
- tabs.add(GSON.fromJson(it.toString(), ChatTab::class.java))
+ val chatTab = GSON.fromJson(it.toString(), ChatTab::class.java)
+ if (chatTab.enabled) {
+ tabs.add(chatTab)
+ }
}
} catch (e: Throwable) {
e.printStackTrace()
@@ -63,8 +74,9 @@ object ChatTabs {
}
private fun generateDefaultTabs(): JsonArray {
- val all = ChatTab("ALL", false, null, null, null, null, null, "")
+ val all = ChatTab(true, "ALL", false, null, null, null, null, null, "")
val party = ChatTab(
+ true,
"PARTY",
false,
listOf("§r§9Party §8> ", "§r§9P §8> ", "§eThe party was transferred to §r", "§eKicked §r"),
@@ -124,6 +136,7 @@ object ChatTabs {
"/pc "
)
val guild = ChatTab(
+ true,
"GUILD",
true,
listOf("Guild >", "G >"),
@@ -134,6 +147,7 @@ object ChatTabs {
"/gc "
)
val pm = ChatTab(
+ true,
"PM",
true,
listOf("To ", "From "),
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt b/src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt
index ede73ad..b3a5e4c 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt
+++ b/src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt
@@ -3,4 +3,9 @@ package com.raeids.stratus.hook
import com.google.gson.JsonArray
import com.google.gson.annotations.SerializedName
-data class ChatTabsJson(@SerializedName("tabs") val tabs: JsonArray, @SerializedName("version") val version: Int) \ No newline at end of file
+data class ChatTabsJson(@SerializedName("tabs") val tabs: JsonArray, @SerializedName("version") var version: Int) {
+
+ override fun toString(): String {
+ return "{\"tabs\": $tabs, \"version\": \"$version\"}"
+ }
+} \ No newline at end of file