Coloring Signs

Discussion in 'Plugin Development' started by GeppiOMG, Nov 8, 2015.

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

    GeppiOMG

    Hey guys i'm having a little problem with coloring signs. I'm basically trying to have it if you type (in a sign):

    &3Hello
    &2Hi
    &1Hey

    it would replace all the color codes with §

    if anyone could help me out with this that would be great ;)
     
  2. Offline

    Zombie_Striker

    @GeppiOMG
    Use the Chatcolor.replaceAlternateChatColor (or something like that) to replace "&" with that symbol\

    Or, you can replace the & with that symbol using String.replace();
     
    Last edited: Nov 9, 2015
  3. Offline

    teej107

     
    Zombie_Striker likes this.
  4. Offline

    GeppiOMG

    Could you tell me how I could do it? if you know how. Thanks!
     
  5. Offline

    Koobaczech

    Lol i got u bra
    Code:
    //Option 1
    //NOT FOR STORING, ONLY FOR PRINTING
    ChatColor.translateAlternateColorCodes('&', YOURSTRING);
    
    //Option 2
    //Hint, use this
    YOURSTRING = YOURSTRING.replaceAll(&, §);
     
  6. Offline

    GeppiOMG

    But how would I get what i wrote? on the sign?
     
  7. Offline

    Koobaczech

    Oh. Well try getting the sign, and then reading its line
    Code:
    //Example get
    Sign s = (Sign) event.getClickedBlock().getState();
    
    //AFTER YOU WRITE TO IT
    String SOMENAME;
    SOMENAME = s.getline(LINENUMBER);
    
     
    Last edited: Nov 17, 2015
  8. Offline

    Mrs. bwfctower

    You shouldn't use this. If you want to store the translated, use
    Code:
    someString = ChatColor.translateAlternateColorCodes('&', someString);
     
    Xerox262 and teej107 like this.
Thread Status:
Not open for further replies.

Share This Page