1.13.2 CitizensAPI Name of NPC only allows for up to 14 Characters

Discussion in 'Spigot Plugin Development' started by Icefox922, Feb 22, 2020.

  1. I have been working with the CitizensAPI to spawn my own player-like mob with it's own characteristics name and everything. Everything seems to be working just fine, except when I type in a name for it to spawn with, it cuts the ends off because it is more than 14 characters. I tried looking into the CitizensAPI source code but I can't seem to find why this issue is occurring. My code is below.

    Set name
    Code (Java):
    npc.setName(BLACK + "Scorpial Guardian");
    Output name
    [​IMG]
     

    Attached Files:

  2. The name can be up to 16 characters, including color codes, the Black means there are two more characters "&0Scorpial Guardian". If you want to extend the player name you need to use team prefix and suffix but i don't know how to do that with citizens npcs
     
  3. If I can't set the name to more than 16 characters, I at least need a second nametag. I know this is possible because I have checked many servers and player entities have a name nametag and a health nametag.

    (PS - I tried casting npc.getEntity() to Player and setting the players custom name but it didn't work. It didn't the name at all. It just kept it blank when I removed the original code setting the name.
    Code (Java):
    Player p = (Player) mob.getNPC().getEntity();
            p.setCustomName(BLACK + "Scorpial Guardian");
            p.setCustomNameVisible(true);
    )
     
  4. That second name tag is actually using scoreboards with DisplaySlot.BELOW_NAME so you know what to dig deeper for. But along with the above response you'll need to utilize a team prefix via scoreboards and all that nonsense.

    But that 16 character limitation is unfortunate, but I believe thats an MC restriction not Citizens
     
  5. Do you know if there is a character limit for the second name tag scoreboard thing? That might solve my problem.
     
  6. I'm sure there is but not finding the limitation with initial searching :(
     
  7. I tried setting up a DisplaySlot.BELOW_NAME scoreboard but it isn't working. It doesn't set anything below the NPC's name. Not sure if this is because of the fact that the NPC is not technically a player or what. Below is the code that I used.
    Code (Java):

        public void spawn(Location loc) {
            npc.spawn(loc);
            board(npc);
        }
        public Scoreboard board(NPC npc) {
            Player p = (Player) npc.getEntity();
            Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
            Team team = board.registerNewTeam("S_G");
            Objective o = board.registerNewObjective("names", "");

            o.setDisplaySlot(DisplaySlot.BELOW_NAME);
            o.setDisplayName(BLACK + "Scorpial Guardian");

            team.addPlayer(p);
            return board;
        }