[Solved] New event API - Get unformatted chat message?

Is there a way to get the unformatted chat message in a MessageSinkEvent using the new event API. Previously with the PlayerChatEvent you could use getUnformattedMessage(), but I can’t find any method that will produce the same results. Is this going to be re-added to the API or will this not be possible in the future?

Thanks

You can use Texts.toPlain(event.getOldMessage()) or Texts.toPlain(event.getNewMessage()).

Unfortunately, none of these are methods in the new event API.

MessageEvent is the parent of MessageSinkEvent, and has getMessage() and a getOriginalMessage() for getting messages.

Texts.toPlain(Text) is definitely still there as well.

I understand that, but none of these return the unformatted message without the player name. I need to get the raw message that the player typed into the chat. Those methods have the name tag included in their message.


Example:
Those methods return something along the lines of: <Flibio> This is a test
I need them to return: This is a test


I can’t just filter out the name by splitting the string on spaces, or something like that because I want this to work even if a chat plugin is installed.

@gratimax will be pushing his new Text Templates branch shortly to SpongeAPI which should address your concerns.

Check the branch here

https://github.com/SpongePowered/SpongeAPI/tree/text-templates

That looks perfect! Thanks!