[solved] About chat event? change format?

Hello,

the default format of chat (<%player%>) is very… bad!

i want to change it… but the event is not PlayerChatEvent, and i’m not sure what do i have to use…

and how verify if it’s player or console?
and change format! plz!

Thx

This is mostly freehand but should give you the general idea

@Listener
public void onMessageEvent(MessageSinkEvent event){
Optional consoleOptional = event.getCause().first(ConsoleSource.class);
if(consoleOptional.isPresent()){
DO STUFF
}
Optional playerOptional = event.getCause().first(Player.class);
if(playerOptional.isPresent()){
DO STUFF
}
}

Thx…
and for change the format it’s …
event.setMessage();

Yes that’ll work

Or you can make a messagesink that formats the message to your liking, then set it on the event. That way plugins that come afterwards see the original message, and not the formatting.

1 Like