Trouble with Color Codes

Discussion in 'Plugin Development' started by dchaosknight, Jul 23, 2012.

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

    dchaosknight

  2. Offline

    beleg

  3. Offline

    dchaosknight

    I tried that, still doesn't work. The problem is, I want the message to be gold by default, but it keeps appearing as dark gray.
     
  4. Offline

    beleg

  5. Offline

    russjr08

    What happens when you try? It doesn't change color?? Try dropping .toString() I don't think it needs it.
     
  6. Offline

    dchaosknight

    russjr08
    I think it does, otherwise the ChatColor.colorname is parsed as a ChatColor object/whatever you call it, and not a String.

    beleg
    The thing is, I want the color to be able to be modified from the config.yml file, not predefined in the code.
     
  7. Offline

    WarmakerT

    ChatColor.translateAlternateColorCode('&', /* Whatever */);
     
  8. Offline

    dchaosknight

    WarmakerT
    Still dark gray... now the onCommand method looks like this:
    Code:
     
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
             Player player = (Player) sender;
             if(commandLabel.equalsIgnoreCase("motd")){
             ChatColor.translateAlternateColorCodes('&', "");
             player.sendMessage(getConfig().getString("MOTD-color") + getConfig().getString("MOTD"));
             }
             return false;
     }
    
     
  9. Offline

    ZeusAllMighty11

    Gold is &6 btw
     
  10. Offline

    beleg

    what do you think is the replaceAll("&", "§") doing in the code I sent you? (pastebin) -.- you just have to configure the message in the config, like that: &4This is red! &3This is idk..
     
  11. Offline

    dchaosknight

    beleg
    what is the ChatColor.GOLD doing in the front, then?
     
  12. Offline

    beleg

    if no other color is set the message is gold
     
  13. Offline

    dchaosknight

    It's just, it seems kind of redundant since the default color is specified in the config.yml file.
     
  14. Offline

    beleg

    you don't get it

    in my code "MOTD-color: '&6' " is removed/unnecessary as you can add colors into "MOTD: Welcome to the server!"
    better example:
    MOTD: &4RED MESSAGE &2OTHER COLOR.. Welcome

    if you understand it now, you see thats better than setting just one color in another config value ;)
     
  15. Offline

    dchaosknight

    Ok, I think I know what the source of the problem is. When the config.yml saves to another location, the color keeps defaulting to §8 instead of &6/§6. How do I fix this?

    beleg
    Thanks, I wasn't thinking about specifying that.
     
  16. Offline

    beleg

    it happens using http://pastebin.com/3qc7jCnh ?? :confused:
     
  17. Offline

    dchaosknight

Thread Status:
Not open for further replies.

Share This Page