From 5639d73f8dc645228cf2da41b1b0a68b4ebbc2db Mon Sep 17 00:00:00 2001 From: Wyvest Date: Wed, 22 Mar 2023 11:12:13 -0400 Subject: fix party tab detection with party join messages Co-Authored-By: XThe <101992755+SirXThe@users.noreply.github.com> --- .../kotlin/cc/woverflow/chatting/chat/ChatTabs.kt | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt') diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt index 8880c83..08423e5 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt @@ -171,6 +171,25 @@ object ChatTabs { json.addProperty("unformatted", false) } } + if (json.has("ends")) { + val ends = json["ends"].asJsonArray + var detected = false + ends.iterator().let { + while (it.hasNext()) { + when (it.next().asString) { + "§r§ehas invited you to join their party!", -> { + detected = true + it.remove() + } + } + } + } + if (detected) { + json.add("contains", JsonArray().apply { + add(JsonPrimitive("§r§ehas invited you to join their party!")) + }) + } + } } fun shouldRender(message: IChatComponent): Boolean { @@ -219,9 +238,8 @@ object ChatTabs { unformatted = false, lowercase = false, startsWith = listOf("§r§9Party §8> ", "§r§9P §8> ", "§eThe party was transferred to §r", "§eKicked §r"), - contains = null, + contains = listOf("§r§ehas invited you to join their party!"), endsWith = listOf( - "§r§ehas invited you to join their party!", "§r§eto the party! They have §r§c60 §r§eseconds to accept.§r", "§r§ehas disbanded the party!§r", "§r§ehas disconnected, they have §r§c5 §r§eminutes to rejoin before they are removed from the party.§r", -- cgit