Make your chat plugin work with others

Discussion in 'Plugin Development' started by Iron_Crystal, Jul 24, 2014.

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

    Iron_Crystal

    Hello,

    I am working on a private chat plugin for my server which adds some prefixes, color, and has chat channels and color in messages, but one thing I noticed was that other plugins don't work with mine because I had to cancel the event and manually send the message to everyone.

    Is there a way to edit the recipients and the prefixes of a message and still allow other plugins to access the event?

    I was hoping to have other plugins like anti-spam or anti-swear plugins work with my plugin, but if there is no way I guess I'll have to implement them into my plugin.
     
  2. Offline

    Bionicrm

    You can try setting the priority of the @.EventHandler to something like Higher or Highest.
     
  3. Offline

    Shevchik

    Stop cancelling the messages and edit recipients instead.
     
  4. Offline

    Iron_Crystal


    That does work when I'm only changing the prefixes and such, but the only way I can see to edit the recipients is to manually send the message to the people I want to hear it.

    Again, there is no "edit recipients" method. I've been manually sending out the messages. If you could explain that would be helpful.
     
  5. Offline

    Traks

    You can just edit the Set returned by AsyncPlayerChatEvent#getRecipients(), as it isn't a copy or immutable/unmodifiable version of the original one.
     
  6. Offline

    Shevchik

    ORLY?
    There is a getRecipients method in AsyncPlayerChatEvent.
     
  7. Offline

    MCForger

    Iron_Crystal
    If you want to add your own custom prefixes, or suffixes that every player can see in game, you could just add a variable for example called "test" in the Essentials config (Chat Section about formatting). Then you check the format on the AsyncChatEvent and if it contains "test" replace "test" with whatever is in your config file as the replacement string. This would only work though if you are using Essentials.
     
  8. Offline

    _Filip

    Hmm try listening on the lowest priority so the other chat plugins get a chance to edit the message.
    You can also use protocol lib to intercept the packetplayoutchat packet.
     
  9. Offline

    Iron_Crystal

    Traks

    I'll try that. I just didn't think it would be a good idea with all the warnings in the Java Docs.

    TheSpherret

    If Traks' idea doesn't work I'll try yours.

    Shevchik

    Not sure your point...Yes I know there is a getRecipients(), but thats different from setRecipients();
     
  10. Offline

    Shevchik

    Remove player from recipients set and he won't receive message. Just like Traks said.
     
Thread Status:
Not open for further replies.

Share This Page