diff options
author | Wyvest <wyvestbusiness@gmail.com> | 2023-03-22 11:12:13 -0400 |
---|---|---|
committer | Wyvest <wyvestbusiness@gmail.com> | 2023-03-22 11:12:13 -0400 |
commit | 5639d73f8dc645228cf2da41b1b0a68b4ebbc2db (patch) | |
tree | 3943d42634e506b133732b56f4cff220dfc1548f | |
parent | a224dcb2a525306d195b8cbf3885392db5316ce2 (diff) | |
download | Chatting-5639d73f8dc645228cf2da41b1b0a68b4ebbc2db.tar.gz Chatting-5639d73f8dc645228cf2da41b1b0a68b4ebbc2db.tar.bz2 Chatting-5639d73f8dc645228cf2da41b1b0a68b4ebbc2db.zip |
fix party tab detection with party join messages
Co-Authored-By: XThe <101992755+SirXThe@users.noreply.github.com>
-rw-r--r-- | docs/chattabs.md | 11 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt | 22 |
2 files changed, 29 insertions, 4 deletions
diff --git a/docs/chattabs.md b/docs/chattabs.md index cb264e5..ca2740d 100644 --- a/docs/chattabs.md +++ b/docs/chattabs.md @@ -28,8 +28,10 @@ something like this: "§eThe party was transferred to §r", "§eKicked §r" ], + "contains": [ + "§r§ehas invited you to join their party!" + ], "ends": [ - "§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", @@ -143,8 +145,11 @@ that you may want to use. "§eThe party was transferred to §r", "§eKicked §r" ], + "contains": [ + "§r§ehas invited you to join their party!" + ], "ends": [ - "§r§ehas invited you to join their party!", + "§r§eto the party! They have §r§c60 §r§eseconds to accept.§r", ... "§r§e because they were offline.§r" ], @@ -204,6 +209,8 @@ The `starts` property allows you to only allow a message if it starts with a str example, if a message which contents were "Hello!", it would not be allowed, as it does not start anything in the `starts` property. +The `contains` property allows you to only allow a message if it contains a string in the `contains` property. + The `ends` property does a similar function, except only allowing a message if it **ends** with anything in the `ends` property rather than if it starts with anything. 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", |