Solved Editing chat message format

Discussion in 'Plugin Development' started by StellarFX, Aug 20, 2021.

Thread Status:
Not open for further replies.
  1. Offline



    My problem is a theoretical problem.
    I am trying to modify the chat messages… And I did it.

    Here is how it works:
    It gets the message, using AsyncPlayerChatEvent (EventPriority is HIGHEST), creates another one based on the format that I want to give it, cancels the event and then broadcasts the just-created BaseComponent using getServer()::broadcast.

    Here is my code, minus all the variables I'm using:


    @EventHandler(priority EventPriority.HIGHEST)
    void chatEvent(AsyncPlayerChatEvent e) {


    BaseComponent[] wholeMessage = new ComponentBuilder(islandLevelFormat).append(userGroupFormat).append(dot).append(userNameFormat).append(guillemet).event((HoverEventnull).append(message).event((HoverEventnull).create();

    And it works like a charm, even the hover event (which is in fact the most important feature) is working:

    But here comes my problem.
    Whenever another plugin asks for input in the chat (and it's supposed not to send the message then), my plugin sends it anyway, which ends up looking like this:


    Is there any way to prevent my plugin from doing that?
    I already tried editing the EventPriority, which results in a different behavior but still not what I want.

    My first lead would be to use packets, but I don't know much about them and I want to know if there is an easier solution before.

  2. Offline

    timtower Administrator Administrator Moderator

    @StellarFX Check if the event is cancelled already?
  3. Offline


    @timtower Oh well, it seems to be working now.
    I wasn't aware of that method… In fact, I wasn't aware that the event would still pass to other plugins.
    Thanks for the quick response time!

Thread Status:
Not open for further replies.

Share This Page