Solved Exceeding the 16 name length

Discussion in 'Spigot Plugin Development' started by illuminator3, Jan 31, 2020.

  1. Hello everyone,

    I'm currently trying to set the player name. (I need to set a prefix)
    Nothing I tried is working. Any ideas?

    (I want the prefix to appear over the player's name)
     
  2. As far as I know you can't exceed the 16 characters limits, but you can use something called String scoller, not exactly what you are looking for through.
     
    • Useful Useful x 1
  3. Have you even read my message?
     
  4. Sorry man I was blind xD
     
    • Funny Funny x 1
  5. FrostedSnowman

    Resource Staff

    The name character limit cannot be exceeded.

    You can only append text before and after the name itself. This is done using scoreboard teams. The teams will allow you to set a prefix and set a suffix. To have the display above the player’s head, use the scoreboard’s associated objective and set the display option to be above the user’s head
     
    • Agree Agree x 1
  6. I'm using scoreboard team suffixes but I can't exceed the 16 char limit.
    This server did it:
    upload_2020-1-31_17-11-17.png
     
  7. Check the wiki they have a solution.
     
  8. I don't know what you mean but for me, it would exceed the char limit.
     
  9. FrostedSnowman

    Resource Staff

    In 1.8, there is a restricted character limit (16) per name, team prefix, & team suffix. You’re limited to 48 characters in total. It’s a downside to using outdated software.

    In 1.13+, the limit was increased to 64.
     
    • Agree Agree x 1
    • Informative Informative x 1
  10. You know that 1.13+ is shit af cuz the combat?
     
    • Funny Funny x 4
  11. SteelPhoenix

    Moderator

    You know that's unrelated to your problem?

    The 16 character limit is hardcoded (both server- and clientside). With 16 chars for both scoreboard team prefix and suffix you can get a maximum of 46 characters like @FrostedSnowman told you.
     
    • Like Like x 2
    • Informative Informative x 1
  12. I can't, if I add a prefix to a team (10 chars) and then add myself to the team (12 chars) it throws an Exception telling me that I exceeded the name length of 16. Even tho the prefix is only 10 chars long.
     
  13. SteelPhoenix

    Moderator

    Then you're doing something wrong and you need to share your code.
     
    • Agree Agree x 2
  14. Sorry for the late reply.


    So here's my code:

    Code (Java):
                if (sb.getTeams().size() == 3)
                {
                    ranks.forEach(r -> sb.registerNewTeam(r.getID() + r.getFirstChar().toLowerCase() + teamName));

                    sb.getTeams().forEach(t ->
                        ranks.forEach(r ->
                        {
                            if (t.getName().equals(r.getID() + r.getFirstChar().toLowerCase() + teamName) && !t.getName().matches("playerCount|playerCoins|friendTeam"))
                            {
                                final String colors = r.getRankColors();

                                if (r.equals(Ranks.RANK8) || r.equals(Ranks.RANK7) || r.equals(Ranks.RANK6))
                                    t.setPrefix(colors);
                                else
                                    t.setPrefix(r.getFormattedName() + " §8❘ " + colors);
                            }
                        })
                    );

                    final Team vanishTeam = sb.registerNewTeam("012vanish" + teamName);

                    vanishTeam.setPrefix("§7");
                }
     
  15. (r.getFormattedName() + " §8❘ " + colors) print this string length to console using System.out
     
  16. Code (Java):
    [19:30:12] [Server thread/INFO]: -----> string: '§4A §8❘ §4' ; length: '10'
    EDIT: I still need help
     
    #17 illuminator3, Feb 1, 2020
    Last edited: Feb 2, 2020
  17. ^
     
  18. I mean, it’s working for me so idk what to tell you man