Remove colour code

Discussion in 'Plugin Development' started by Rprrr, Jan 16, 2013.

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

    Rprrr

    Hi,

    One quick question.

    I put this string in the lore of an item:
    Code:
    (ChatColor.GRAY + 1)
    Now, I'm getting that string from the lore again, like so:
    Code:
                    String idstring = lore.get(4);
    I want to parse the integer from the idstring. But this is impossible, because I have this 'ChatColor.GRAY' thing - how do I get rid of this so I can get my integer?

    Thanks in advance!

    (The answer is probably very simple but I can't figure it out :l)
     
  2. Offline

    caseif

    Code:java
    1. idstring.replace("ChatColor.GRAY ", "");
     
  3. Offline

    Jombi

    First of all, that doesn't make much sense to apply a color code to an integer that isn't being parsed to chat or something. Can you show more code?
     
  4. To remove ALL colours, its ChatColor.stripColor(string here);
     
  5. Offline

    Rprrr

    It's displayed in the lore of an ItemStack. I didn't want to have that ugly, purple italic lore text, so I changed to to a gray colour.

    AngryNerd thebigdolphin1
    Thanks, I'll try those things. :)
     
  6. Offline

    caseif

    For future reference, I've found that using alternate color codes is a bit easier. For example, my plugin creates items with green title, so the string would be (section symbol)2[name]. Then, I can just do a normal check, except I would include the section symbol and number as well as the title.
     
Thread Status:
Not open for further replies.

Share This Page