I was making a chat plugin and made a listener.
If I join the server, leave or send a message, the listener is triggered,
but if I or console use '/say ’ or '/tell ',
there is only a CommandSendEvent, no MessageEvent or MessageChannelEvent.
When I use a command, and I get a response (like ‘Unknown Command’ or 'Teleported to '),
the listener isn’t triggered too.
So, what I want, is a listener that will be triggered when there is something added to a players chat screen. This could be:
How much RAM does the machine running the server have? I suggest having at least 2GB to run the server. Make sure to give java a reasonable amount with -Xms2G -Xmx2G
Here are some answers for your questions, as best as I can get them:
You can use event.getMessage().toPlain() to read the text as a String, and you can parse that string to determine what you want from there.
That’s the message which is sent to the client, not the message pre-formatting. Any message attained this way will be what the client sees, not what the client sends.
Since they all call the same method to send the player the message, there is no surefire way of knowing what triggered the event. Your best bet is to look at the message that is sent to the player and try to determine it based on that.
If you want to change specifically those commands, i would suggest overwriting them with your own commands.
However you did not tell us what exactly you want to do, so beware of the XYProblem ^^
Then only format MessageChannelEvent.Chat and for /tell and /say create two new commands (with the same labels: ‘tell’ and ‘say’) wich do the same, but formatted in your way.