Formating elements of a list

Discussion in 'Plugin Development' started by wydgabriel, Jul 9, 2016.

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

    wydgabriel

    Hello guys
    I created a list of default items in my config but I cant get to format the ColorCodes of them

    http://pastebin.com/9ysxGU6a

    How can I transform this color codes to codes in-game?
    They get to my inventory like this: http://prntscr.com/bqz8c8

    Idk if you guys understood what I was trying to say, but yea, i'm having this problem with color codes.

    Thank you!!
     
  2. Offline

    mine-care

    So, you are trying to translate color codes for a string so that they show ingame?
    Use ChatColor#translateAlternateColorCodes(char colorChar,String str); for that where colorChar is the character you use in the config to represent color codes (typically '&') and str is the text to translate the color of.
     
  3. @wydgabriel
    Just display it as it is. It will automatically put the colour in for you
     
  4. Offline

    SuperSniper

    To addon to what @mine-care said above.

    Code:
    ChatColor.translateAlternateColorCodes('&', "string");
    // This allows you to use & for color codes.
    
    So, if you wanted to get something from the config, use this:

    Code:
    ChatColor.translateAlternateColorCodes('&', getConfig().getString("string"));
    
     
    mine-care likes this.
  5. Offline

    wydgabriel

    I know that, but how to get this kind of string?
    Did you guys see my config? How can I get this string path?
     
Thread Status:
Not open for further replies.

Share This Page