Solved Turning ChatColor into strings

Discussion in 'Plugin Development' started by Hex_27, Sep 26, 2015.

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


    Is there a way to convert chatcolors to strings to be saved in a config?
    ChatColor.DARK_RED + "hi"


  2. Offline


    You can use ChatColor#translateAlternateColorCodes(char c, String s)
    inside of your config. For example:

    String message = ChatColor.translateAlternateColorCodes('&', getConfig().getString("test));
  3. Offline


    @Hex_27 ChatColors can be saved in the config no problem.
  4. Offline


    No. I don't want that. Read my post again. I want to do the literal opposite of what you're doing there.

    Can it be saved in the way I put in the Original Post? I need the users to understand the saved colorcodes
    Last edited: Sep 27, 2015
  5. Online

    timtower Administrator Administrator Moderator

    Why not save them as readable and load them as translated strings in the onEnable?
    This is able to find the used ChatColors, you can modify it to return the strings as you need them.
  6. If you print out ChatColor.DARK_RED it actually prints out "ยง4". I don't know what you want
  7. Offline


    @FisheyLP I guess users can understand that, and there would be no need for me to write any code to change it. Thanks

    @FisheyLP okay, I just tried it, and no it didn't save it that way. It saved it like this

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
    Last edited by a moderator: Sep 27, 2015
  8. Offline


  9. Offline


    @Hex_27 This is the best option. It's simple and the users won't tell a difference.
    timtower likes this.
  10. Offline


    Yep, this works :D. Just what I was looking for.

    I would. But, I need to save items with colored lores and display names in the game itself. It is much simpler with a colorize and decolorize method
Thread Status:
Not open for further replies.

Share This Page