Adding color codes to broadcast command

Discussion in 'Plugin Development' started by Fhbgsdhkfbl, May 11, 2014.

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

    Fhbgsdhkfbl

    Hey bukkit forums, I made a /broadcast command but it doesn't work with color codes like &4

    if you know how to add those in, I'd really appreciate if you direct me in the right path! :3

    Code:
    f(label.equalsIgnoreCase("broadcast") || label.equalsIgnoreCase("bc")) {
    if(p.hasPermission("p.mod")){
    String message = "";
    for (String part : args) {
       if (message != "") message += " ";
       message += part;
    }
    Bukkit.getServer().broadcastMessage(ChatColor.GOLD + "[" + ChatColor.DARK_RED + "Sonorus" + ChatColor.GOLD + "] " + ChatColor.RED + message + " - " + p.getName());
    } else {
    p.sendMessage(ChatColor.RED + "You must be a Teacher or Junior-Teacher to use this command!");
    return true;
    }
    }
     
  2. Offline

    tryy3

    on the broadcastMessage, do
    Code:java
    1. ChatColor.translateAlternateColorCodes('&', message)

    instead of message
     
    es359 likes this.
  3. Offline

    Fhbgsdhkfbl

    tryy3
    thank you so much!
     
  4. Offline

    qlimax5000

    Please mark thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page