From 38b90b102a50f886362f919df3940e667d8f2366 Mon Sep 17 00:00:00 2001 From: Boy Date: Fri, 29 Dec 2023 15:24:12 +0100 Subject: [PATCH] chore: use simpleMessage for hover-deletion messageHistory & logging --- .../kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt | 5 ++--- .../com/mineinabyss/chatty/listeners/ChatListener.kt | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt index c79fa80..bc85730 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt @@ -9,7 +9,6 @@ import com.mineinabyss.chatty.components.ChannelData import com.mineinabyss.chatty.components.ChannelType import com.mineinabyss.chatty.components.chattyNickname import com.mineinabyss.chatty.placeholders.chattyPlaceholderTags -import com.mineinabyss.geary.papermc.tracking.entities.toGeary import com.mineinabyss.idofront.textcomponents.miniMsg import com.mineinabyss.idofront.textcomponents.serialize import me.clip.placeholderapi.PlaceholderAPI @@ -217,13 +216,13 @@ fun appendChannelFormat(message: Component, player: Player, channel: ChattyChann fun Component.hoverEventShowText(text: Component) = this.hoverEvent(HoverEventSource.unbox(HoverEvent.showText(text))) -fun formatModerationMessage(messageDeletion: ChattyChannel.MessageDeletion, message: Component, signedMessage: SignedMessage, audience: Audience, source: Player, viewers: Set): Component { +fun formatModerationMessage(messageDeletion: ChattyChannel.MessageDeletion, message: Component, messageHistory: Component, signedMessage: SignedMessage, audience: Audience, source: Player, viewers: Set): Component { fun Component.appendDeletionHover(player: Player): Component { return when (chatty.config.chat.disableChatSigning) { true -> this.hoverEventShowText(Component.text("Chat-Signing is disabled, messages cannot be deleted.", NamedTextColor.RED)) false -> this.hoverEventShowText(chatty.messages.messageDeletion.hoverText.miniMsg()) .clickEvent(ClickEvent.callback { - val hoverString = Component.empty().hoverEventShowText(message).serialize() + val hoverString = Component.empty().hoverEventShowText(messageHistory).serialize() if (!signedMessage.canDelete()) return@callback player.sendFormattedMessage(hoverString + chatty.messages.messageDeletion.deletionFailed) diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt index e4d11fd..f0af552 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt @@ -4,6 +4,7 @@ import com.mineinabyss.chatty.chatty import com.mineinabyss.chatty.chattyProxyChannel import com.mineinabyss.chatty.components.ChannelData import com.mineinabyss.chatty.components.CommandSpy +import com.mineinabyss.chatty.components.chattyNickname import com.mineinabyss.chatty.helpers.* import com.mineinabyss.geary.datatypes.family.family import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull @@ -16,6 +17,8 @@ import io.papermc.paper.event.player.AsyncChatDecorateEvent import io.papermc.paper.event.player.AsyncChatEvent import net.kyori.adventure.text.Component import net.kyori.adventure.text.format.NamedTextColor +import net.kyori.adventure.text.format.Style +import net.kyori.adventure.text.format.TextDecoration import net.kyori.adventure.text.minimessage.MiniMessage import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer import org.bukkit.Bukkit @@ -70,7 +73,7 @@ class ChatListener : Listener { player.sendPluginMessage(chatty.plugin, chattyProxyChannel, proxyMessage) } - val simpleMessage = player.name().append(Component.text(": ", NamedTextColor.WHITE)).append(message()) + val simpleMessage = Component.textOfChildren(player.name().style(Style.style(TextDecoration.ITALIC)), Component.text(": "), message()) if (channel.logToConsole) Bukkit.getConsoleSender().sendMessage(simpleMessage) val pingedPlayer = originalMessage().serialize().checkForPlayerPings(channelId) @@ -85,6 +88,7 @@ class ChatListener : Listener { finalMessage = formatModerationMessage( channel.messageDeletion, finalMessage, + simpleMessage, signedMessage(), receiver, player, @@ -104,6 +108,7 @@ class ChatListener : Listener { finalMessage = formatModerationMessage( channel.messageDeletion, finalMessage, + simpleMessage, signedMessage(), audience, source,