aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 13:45:51 -0500
committerWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 13:45:51 -0500
commite574e54a53b87ef4bbb33404b6fdb6b97c72dd81 (patch)
tree62bc726b1f0eb4727b6ddf10696f1fa69c519806 /src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
parent27aa4095270f943ddab2a4e4d370e225766c7ff7 (diff)
downloadChatting-e574e54a53b87ef4bbb33404b6fdb6b97c72dd81.tar.gz
Chatting-e574e54a53b87ef4bbb33404b6fdb6b97c72dd81.tar.bz2
Chatting-e574e54a53b87ef4bbb33404b6fdb6b97c72dd81.zip
allow selecting multiple chat tabs at the same time
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt')
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
index cb95c53..c2329b4 100644
--- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
@@ -16,15 +16,16 @@ object ChatTabs {
private val GSON = GsonBuilder().setPrettyPrinting().create()
private val PARSER = JsonParser()
val tabs = arrayListOf<ChatTab>()
- var currentTab: ChatTab? = null
- set(value) {
- if (value != null) {
- field = value
- if (Minecraft.getMinecraft().theWorld != null) {
- Minecraft.getMinecraft().ingameGUI.chatGUI.refreshChat()
- }
+ var currentTabs: ArrayList<ChatTab?> = object : ArrayList<ChatTab?>() {
+ override fun add(element: ChatTab?): Boolean {
+ if (element == null) return false
+ val returnValue = super.add(element)
+ if (Minecraft.getMinecraft().theWorld != null && returnValue) {
+ Minecraft.getMinecraft().ingameGUI.chatGUI.refreshChat()
}
+ return returnValue
}
+ }
private var initialized = false
private val tabFile = ConfigUtils.getProfileFile("chattabs.json")
@@ -49,7 +50,8 @@ object ChatTabs {
tabs.forEach {
it.initialize()
}
- currentTab = tabs[0]
+ currentTabs.clear()
+ currentTabs.add(tabs[0])
}
private fun handleFile() {
@@ -171,7 +173,13 @@ object ChatTabs {
}
fun shouldRender(message: IChatComponent): Boolean {
- return currentTab?.shouldRender(message) ?: true
+ if (currentTabs.isEmpty()) return true
+ for (tab in currentTabs) {
+ if (tab?.shouldRender(message) == true) {
+ return true
+ }
+ }
+ return false
}
private fun generateNewFile() {