PlayerChatEvent.setNewMessage

I’m trying to change the format of a chat message under certain conditions, but the name and message placeholders don’t get replaced with the player’s name and the player’s message.

Is this because it hasn’t been implemented yet, or am I doing something wrong?

Wrong Code:

Texts.of("[" + PlayerChatEvent.PLACEHOLDER_NAME + "] " + PlayerChatEvent.PLACEHOLDER_MESSAGE)

Right Code:

Texts.of("[", Texts.placeholder(PlayerChatEvent.PLACEHOLDER_NAME), "] ", Texts.placeholder(PlayerChatEvent.PLACEHOLDER_MESSAGE))

What exactly is the difference between Texts.placeholder(PlayerChatEvent.PLACEHOLDER_NAME)
and event.getUser().getName() ?

@DarkIce It’s overall better to use placeholders in case another plugin changes the name or reformats the message.

1 Like