Colour on signs

Discussion in 'Plugin Development' started by Elimnator, Jul 25, 2013.

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

    Elimnator

    I have:
    Code:
    event.setLine(3, "§e" + players + "§0/§e" + maxplayers + " §0Online");
    But it thinks the "§e" (colour codes) are characters, so it only displays: "0/12 On"

    Anyone know a way to fix this?
     
  2. Offline

    Tomskied

    Use
    Code:java
    1. event.setLine(3, ChatColor.translateAlternateColorCodes('&',"&e" + players + "&0/&e" + maxplayers + " &0Online");
     
  3. Offline

    Elimnator

    It says "ChatColor can not be resolved".
     
  4. Offline

    xTrollxDudex

  5. Offline

    Elimnator

  6. Offline

    xTrollxDudex

    Elimnator
    Is the error still there?
    You can always use the ChatColor enumeration.
     
  7. Offline

    Elimnator

    xTrollxDudex
    There is no error, is just still shows only: "0/12 On" not "0/12 Online" like it should.

    Edit: What's ChatColor enumeration?
     
  8. Offline

    xTrollxDudex

    Elimnator
    The chat color enumeration is the long verion of "enum", just do ChatColor.BLACK + "text here" + ChatColor.RED + "more text". All the chat colors can be found on the javadocs.
     
  9. Offline

    Tomskied

    Oh, I think I know what you mean now. You cant stop chat chars from being seen as a char. So ChatColor.BLACK or my method, or your §0 will still take up space, hence why you cant fit your line on.
     
  10. Offline

    Elimnator

    Tomskied
    xTrollxDudex

    I did this and it still wont show the maxplayers variable.
    Code:
    event.setLine(3, "Players: " + ChatColor.YELLOW + players + ChatColor.BLACK + "/" + ChatColor.YELLOW + maxplayers);
     
  11. Offline

    Tomskied

    A line of text on a sign is 15 chars max long.
    "Players: " 9 chars. ChatColor.YELLOW 2 chars, players probably 1-2 chars, ChatColor.BLACK 2 chars, "/" 1 char, ChatColor.YELLOW 2 chars, maxplayers, probably 1-2 chars.
    Even if the max players and players is lower than 10, thats still 18 chars. Too many for one line.
     
  12. Offline

    Elimnator

    Tomskied
    I thought ChatColor.YELLOW didn't count as characters.

    How do I change the colour but not use up characters?
     
  13. Offline

    Tomskied

  14. Offline

    Ewe Loon

    if i'm not mistaken you need to use "//" in the string not "/" to get a single "/" charactor after compiling
     
  15. Offline

    Elimnator

    Well I did:
    Code:
    event.setLine(3, "Players: " + ChatColor.YELLOW + players + "/" + maxplayers);
    And it worked, so you must be mistaken.
     
Thread Status:
Not open for further replies.

Share This Page