Solved Color codes in plugin.yml

Discussion in 'Plugin Development' started by SchulziHD, Dec 20, 2012.

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

    SchulziHD

    Is it possible to use color codes in the plugin.yml?
    For example for the permission-message.
    Code:
    permission-message: &CYou do not have permission...
    Because when I use it, it won't change the color to red. It keeps white.
    So I wanted to know if it is possible to use colors in the plugin.yml.
     
  2. Offline

    fireblast709

    use '§' instead of '&'
     
  3. Offline

    zRations

    Just use the simple
    Code:
    ChatColor.translateAlternateColorCodes('&', String);
     
    zeeveener likes this.
  4. Offline

    zeeveener

    You can do what zRations says. It works perfectly fine and is shorter.
    However, if you'd like to add custom codes, you can also do this:
    Code:java
    1. public String colorize(String msg){
    2. String newMsg = msg.replaceAll("&0", ChatColor.BLACK);
    3. newMsg = newMsg.replaceAll("&1", ChatColor.DARK_BLUE);
    4. newMsg = newMsg.replaceAll("&newline", "\n");
    5. .
    6. .
    7. .
    8. return newMsg;
    9. }
     
  5. Offline

    DarkBladee12

    But you have to write this in the config:

    Code:
    permission-message: '&CYou do not have permission...'
    You have to mark this as a string with '', otherwise the plugin will throw an error, because a value can't start with an "&".
     
  6. Offline

    SchulziHD

    Throws error (not allowed to use).

    So it is not possible to set the color in the plugin.yml itself?
    Thanks for your replies!
     
  7. Offline

    zRations

    Not without doing what I or zeeveener said.
     
  8. Offline

    SchulziHD

    Ok, thanks.
     
  9. Offline

    ImDeJay

    Here is what i use when im going to use any type of colors in any .yml

    Code:
    static String replaceColors(String message) {
     
    return ChatColor.translateAlternateColorCodes('&', message);
     
     }
    Then when your sending the player a message do

    Code:
    String MSG = replaceColors(this.getconfig().getstring(path, string));
     
    player.sendmessage(MSG);
     
Thread Status:
Not open for further replies.

Share This Page