Solved Using RGB/Hex colors in Scoreboard

Discussion in 'Spigot Plugin Development' started by MrFlovi, Sep 29, 2020.

  1. Is it possible to use Hex colors in a Scoreboard?
    It doesn't work with Bungee's ChatColor, and it seems as if the Scoreboard only supports the standard Minecraft ChatColors.
    Code (Java):
    Score timeleft = obj1.getScore(ChatColor.of("#ff0000") + "Not enough players...");
    This code should make my text red, but it makes it black. I appears that when I change the last char in the string, for example change it to "#ff0004", the text becomes dark red, just like the color code for dark red is 4, and for black is 0.

    Is there anything I can try? Or is it just not possible?

    Edit: It seems to only not work in the Scores. in the title I can user ChatColor just fine.
    #1 MrFlovi, Sep 29, 2020
    Last edited: Sep 29, 2020
  2. I know it does work on scoreboards, I'm not sure of the exact code but it should work fine. Just make sure you are testing using the standard Minecraft launcher and not a different client like BLC.
  3. I am testing with the normal Minecraft Launcher, so everything should be fine, but it doesn't seem to work. Do I need to use something other than ChatColor to make this work?

    Nothing else has worked so far. I tried using this but also didn't work, as I got black text again:
    Code (Text):
    Score timeleft = obj1.getScore(ChatColor.of(new Color(255, 0, 0)) + "Not enough players...");
    Any other ideas?
  4. Try
    Code (Java):
  5. I'm afraid that didn't work. I tried that earlier as well, sorry for not mentioning earlier.
  6. "Hex codes are only for JSON text."

    I think the scoreboard doesn't use JSON text (not sure tho). :unsure:
  7. Yeah you are right, I did some researching and found out that at least until 1.13 this has been the case.

    But I have seen images of people making RGB scoreboards work, just haven't been able to found out how they did it. Stringbuilder? TextComponent? I really don't know
  8. I didn't find anything useful, probably because I didn't understand what was going on most of the time.

    I've spent the last 6 hours looking through repos and threads trying to find the solution, but was unsuccesful.
    Does nobody know how to do this? I've seen plenty of Scoreboard plugins supporting rgb/hex colors
  9. I'm just giving you some examples of the code of other developers. Maybe it's also possible with the Bukkit API. I'm not sure.

    EDIT: Found this:
    So I think you must import the bungee ChatColor class to make them work?
    • Friendly Friendly x 1
  10. In my first post you can find my code where I use the bungee ChatColor class, but the problem is, that it doesn't work sadly.
    It only seems to work in the Title of the Scoreboard, but for the Scores the color changes to a legacy color (color pre 1.16).
  11. Is there a solution to this yet?
    #15 Kjzl, Oct 14, 2020
    Last edited: Oct 14, 2020
  12. bump
    • Optimistic Optimistic x 1
  13. Currently the API doesn't support RGB for scoreboards. You likely need to pr that.
  14. If you use teams for your scoreboard you can set the score to use a hidden value (using colour codes) and then just set the teams prefix or suffix and that works fine in my case. To what I can gather though is there are still a few things that can't be set using hex values such as the score specially and also a team is still limited to the 16 base colours so you can't set a players name tag to be rgb either. Just using teams will work though for your case.
    • Informative Informative x 1
    • Friendly Friendly x 1