Broadcast Event

Discussion in 'Plugin Development' started by audhen, Dec 15, 2011.

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

    audhen

    Hi there!

    Is it possible to catch/make an event regarding Server.broadcastMessage() ?
     
  2. Offline

    Chiller

    You are a bit too broad on what you want help on... Please explain more.
     
  3. Offline

    audhen

    I'd like to get all kinds of output.
    E.g. the player chats and also the broadcasted messages.

    I'd be looking for Event.Type.SERVER_BROADCAST // onServerBroadcast().
    But there is no, so I'm looking for an approach to get those messages.

    Thank you in advance!
     
  4. Offline

    Perdog

    From the sounds of it you're trying to get a players chat? If so you don't need the broadcast. There is onPlayerChat(PlayerChatEvent event) which should work if you are trying to do what I think you are trying to do :p
     
  5. Offline

    audhen

    I need also the broadcast, it's the crucial point :D
     
  6. Offline

    MDCreator

    A search through the javadocs shows no signs of any broadcast event. I'm not sure if custom events would work or maybe modifying the Bukkit broadcast function to also function as an event...
     
  7. Offline

    audhen

    Hmm, that's a pity...
    I don't like the idea to alter the bukkit-Code :/

    Hmm, no other ideas? :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  8. Offline

    Father Of Time

    The PlayerChatEvent has two variables inside, a message and formatting. I am only speculating but I would imagine the broadcast utilizes this formatting variable.

    If I were you I would make a PlayerChatEventListener, and every single time its triggered print the message and formatting to the console. Then say 10 things normally and 10 things as a broadcast to look for a pattern. If you have noticed all broadcast are Green and formatted like “<Broadcast>, so I would imagine its formatting variable looks like something like this:

    “&7<Broadcast>&0”

    And if so you could simply put this check inside the event:

    Code:
    If( event.getFormatting.equalsIgnoreCase(“&7<Broadcast>&0” );
    {
            // you’ve identified a broadcast
    }
    
    Unfortunately I am only guessing, so it’s very possible this won’t work, but if I were taking shots in the dark this would be something I would try.

    I hope this helps, Good luck with your project.

    p.s. Ugg I had to write this twice, I accidentally closed my browser :D
     
  9. Well, the thing is he is looking for an event for a broadcast like /say blabla from the console or Server.broadcast("Hi").
    Unfortunately it doesn't fire any events.

    @Father Of Time
    I spent 5 minutes looking for proof that Server.broadcastMessage("") doesn't fire any events, and then you just remove your post <.< :p

    Anyways as you can see here, theres no events being fired.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  10. Offline

    Father Of Time

    Sorry, I removed it just for that reason, I realized afterward that I had no proof of whether it was triggered or not, and upon further research determined that it was not.
     
  11. Offline

    audhen

    Too bad :/
    Ok, thank you for your efforts!
    Happy x-mas time :)
     
    Father Of Time and r3Fuze like this.
  12. Happy christmas to you too :)
     
  13. Offline

    Father Of Time

    Happy Holidays to you as well. :D
     
Thread Status:
Not open for further replies.

Share This Page