From 1505b39ff21557fc6b169241480fece84770b128 Mon Sep 17 00:00:00 2001 From: Nicholas Rose <35816886+nicholasgrose@users.noreply.github.com> Date: Tue, 27 Dec 2022 00:49:57 -0500 Subject: [PATCH] Fixed issues with Minecraft chat parsing --- .../chat/processing/ConvertToDiscordMessage.kt | 15 ++++++++------- .../tokens/RoleQuoteMentionTokenProcessor.kt | 2 +- .../tokens/UserQuoteMentionTokenProcessor.kt | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt index c5713a00..4654b669 100644 --- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt +++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt @@ -16,13 +16,13 @@ import io.papermc.paper.event.player.AsyncChatEvent private val textProcessor = TextProcessor( listOf( - UserMentionTokenProcessor(), - UserQuoteMentionTokenProcessor(), - RoleMentionTokenProcessor(), - RoleQuoteMentionTokenProcessor(), - TextChannelMentionTokenProcessor(), - VoiceChannelMentionTokenProcessor(), UrlTokenProcessor(), + VoiceChannelMentionTokenProcessor(), + TextChannelMentionTokenProcessor(), + RoleQuoteMentionTokenProcessor(), + RoleMentionTokenProcessor(), + UserQuoteMentionTokenProcessor(), + UserMentionTokenProcessor(), TextTokenProcessor() ) ) @@ -72,10 +72,11 @@ suspend fun discordMessageWithContent( contentProvider: (MessageProcessingResult) -> String ): (MessageCreateBuilder.() -> Unit)? { val result = processMessageText(message) + val discordContent = contentProvider(result) return if (result.successful) { { - content = contentProvider(result) + content = discordContent } } else null } diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt index d191b38f..610bc972 100644 --- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt +++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt @@ -28,7 +28,7 @@ class RoleQuoteMentionTokenProcessor : TokenProcessor