Skip to content

Commit

Permalink
chore: use simpleMessage for hover-deletion messageHistory & logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Dec 29, 2023
1 parent dbdfb21 commit 38b90b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Player>): Component {
fun formatModerationMessage(messageDeletion: ChattyChannel.MessageDeletion, message: Component, messageHistory: Component, signedMessage: SignedMessage, audience: Audience, source: Player, viewers: Set<Player>): 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)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -85,6 +88,7 @@ class ChatListener : Listener {
finalMessage = formatModerationMessage(
channel.messageDeletion,
finalMessage,
simpleMessage,
signedMessage(),
receiver,
player,
Expand All @@ -104,6 +108,7 @@ class ChatListener : Listener {
finalMessage = formatModerationMessage(
channel.messageDeletion,
finalMessage,
simpleMessage,
signedMessage(),
audience,
source,
Expand Down

0 comments on commit 38b90b1

Please sign in to comment.