How to make 2 plugins that use onChat event compatible?

Discussion in 'Plugin Development' started by nossr50, Feb 4, 2011.

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

    nossr50

    I have two plugins I'm working on that both use the onChat event, they are for the most part compatible but sometimes there is double sending of messages. For example in plugin 'a' when OPs speak their brackets are colored red, in plugin 'b' this is not so, so both messages will be sent. How do I make it so plugin 'b' will not send its message if plugin 'a' is handling the event?

    I tried putting this into plugin 'b's onChat event
    Code:
    if(event.isCancelled())
            {
            return;
            }
    Still causes 2 messages to send when the player is an OP
     
  2. Offline

    mindless728

    in plugins b's onChat event check to see if plugin a is there and enabled, if so do nothing
    Code:
    Plugin a = getServer().getPluginManager().getPlugin(pluginAName);
    if(a != null && a.isEnabled())
        return;
    .....
    
     
  3. Offline

    nossr50

    Hmm this doesn't exactly fix my problem it seems. To further elaborate...
    Plugin 'a' has party chat, and admin chat
    Rather than disabling plugin b just because plugin a is running, I want to be able to choose whether or not plugin 'b' should be able to fire in plugin 'a's code, is there any way to achieve such a thing?

    Like when plugin 'a' uses admin chat and party chat, I want it to tell plugin 'b' to not do shit or somehow achieve squelching of plugin 'b'.
     
  4. Offline

    mindless728

    well i suppose you could create a custom event that plugin B fires that plugin A receives via listeneing on custom events
     
Thread Status:
Not open for further replies.

Share This Page