Skip to content

Commit

Permalink
Add default minecraft formatting if formatting is not supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Oct 13, 2024
1 parent 902d171 commit a96ef54
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSy
import com.github.shynixn.mccoroutine.bukkit.registerSuspendingEvents
import com.typewritermc.engine.paper.plugin
import com.typewritermc.engine.paper.snippets.snippet
import com.typewritermc.engine.paper.utils.asMiniWithResolvers
import com.typewritermc.engine.paper.utils.plainText
import lirand.api.extensions.server.server
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import net.kyori.adventure.text.format.TextColor
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
Expand Down Expand Up @@ -61,7 +63,13 @@ class ChatHistoryHandler :
PacketType.Play.Server.CHAT_MESSAGE -> {
val packet = WrapperPlayServerChatMessage(event)
val message = packet.message as? ChatMessage_v1_19_3 ?: return packet.message.chatContent
message.unsignedChatContent.orElseGet { message.chatContent }
message.unsignedChatContent.orElseGet {
// Use the default minecraft formatting
"\\<<name>> <message>".asMiniWithResolvers(
Placeholder.component("name", message.chatFormatting.name),
Placeholder.component("message", message.chatContent)
)
}
}

PacketType.Play.Server.SYSTEM_CHAT_MESSAGE -> {
Expand Down

0 comments on commit a96ef54

Please sign in to comment.