Non-player Chat Messages

Discussion in 'Plugin Development' started by Malkierian, Feb 23, 2012.

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

    Malkierian

    Is there an easier way to send a "chat" message from a plugin than using sendMessage(String) on each online player?
     
  2. Offline

    acuddlyheadcrab

    Bukkit.broadcastMessage("this shows up on everyone's screen");

    Copied directly from a working plugin class.
     
  3. Offline

    Malkierian

    Ah, I didn't realize that allowed for color formatting.

    Also, inside of onPlayerChat, how do I make it so that any broadcasts or messages are sent AFTER the chat goes through, instead of BEFORE, which it's doing right now?
     
  4. Offline

    acuddlyheadcrab

    Yes.
    ...because ChatColor consists of a special unicode byte character that Minecraft sees as a color changer.

    I'm thinking about how to fix the other problem.

    A somewhat messy work-around for that would be to use the schduler...

    Here's what I tested:

    Code:java
    1. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {public void run() {
    2.  
    3. Bukkit.broadcastMessage(ChatColor.RED+"Message goes here");
    4.  
    5. }}, 1L);


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

    Malkierian

    That'll do quite nicely for now, thanks.
     
  6. Offline

    acuddlyheadcrab

    Caveat: It may return some obscure errors if there's something that lags the server at the moment chat is send.
     
Thread Status:
Not open for further replies.

Share This Page