diff options
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/chat/Bridge.kt')
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/Bridge.kt | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main/kotlin/dulkirmod/features/chat/Bridge.kt b/src/main/kotlin/dulkirmod/features/chat/Bridge.kt index 88430af..326ab96 100644 --- a/src/main/kotlin/dulkirmod/features/chat/Bridge.kt +++ b/src/main/kotlin/dulkirmod/features/chat/Bridge.kt @@ -8,9 +8,11 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent object Bridge { private val guildFormat = - "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+) > .+".toRegex() + "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([\\w ]+) > .+".toRegex() private val alternateFormat = - "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+): .+".toRegex() + "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([\\w ]+): .+".toRegex() + private val otherAltFormat = + "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([\\w ]+) » .+".toRegex() fun handle(event: ClientChatReceivedEvent) { val message = event.message.unformattedText @@ -44,5 +46,20 @@ object Bridge { ).setChatStyle(event.message.siblings[1].chatStyle.createShallowCopy()) } } + + else if (otherAltFormat matches message && Config.bridgeBot) { + val matchResult = otherAltFormat.find(message) + val (prefix, name, playerName) = matchResult!!.destructured + if (Utils.stripColorCodes(name.lowercase()) == Config.botName.lowercase()) { + val newPrefix = if (prefix == "§2Guild") "§2Bridge" else "§3Bridge" + val color = if (Config.bridgeColor == 16) "§z" else EnumChatFormatting.values()[Config.bridgeColor] + event.message.siblings[0] = ChatComponentText( + "$newPrefix > $color$playerName§f: " + ) + event.message.siblings[1] = ChatComponentText( + event.message.siblings[1].unformattedText.replace("$playerName: ", "") + ).setChatStyle(event.message.siblings[1].chatStyle.createShallowCopy()) + } + } } }
\ No newline at end of file |