Solved The received string length is longer tham maxium allowed

Discussion in 'Spigot Plugin Development' started by GustavoTryhard, Jun 24, 2021.

  1. I created a plugin to create an npc. When I build using the command I created to test it works normally. But when I put to create when the player enters the server it shows this error.
    [​IMG]
    I know why it shows this error, but I don't know what to do to fix it. My code:

    Code (Java):
    public class Npc {
        private EntityPlayer npc;
        public void createNPC(Player player, String npcName) {
            MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
            WorldServer nmsWorld = ((CraftWorld) Bukkit.getWorld("Lobby")).getHandle();
            GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "§a§l" + npcName);
            changeSkin(gameProfile);

            EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile, new PlayerInteractManager(nmsWorld));
            Player npcPlayer = npc.getBukkitEntity().getPlayer();
            npcPlayer.setPlayerListName("");
            npc.setLocation(-6, 63, 1, -6, -6);

            PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));

        }
        private void changeSkin(GameProfile profile){
            File npcConfig = new File("Configs/LobbyNPC/config.yml");
            new YamlConfiguration();
            YamlConfiguration config = YamlConfiguration.loadConfiguration(npcConfig);
            profile.getProperties().put("textures", new Property("textures",config.getString("texture"),config.getString("signature")));

        }
    }
    Configs/LobbyNPC/config.yml ↓

    Code (YAML):
    texture: ewogICJ0aW1lc3RhbXAiIDogMTYyNDQ4MjE2NTMyOCwKICAicHJvZmlsZUlkIiA6ICJhZjUyMjhjODJhZTI0N2NjYTA3MjBmMGVjNWU4Mjk4YSIsCiAgInByb2ZpbGVOYW1lIiA6ICJzYW1qb2swIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIyNWRkYTUwZWU0ZDFlY2VmMDMzZjZmNzU0YmIzMDZkYmE2NjFiNjI4ZTQwMTY3NDgwNDkxMTViOGRjZDkxMjgiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==

    signature
    : N6LloseuJvgDsjfDwnSjNC8u0WkIakFOnlXCy2FC1SwrrKdV1e+1+wBtImlJUCHL9TWcaIyVyIfwQI6pVjxrkfSwa2U9IsQ3fDaXWVL4WPDzRsnxIckxk9yImDW0JIJhen6Xzim4TQP1Sxt9duIjw8BwsOmAG6GfpgELs8tJC73OBVqvd7HdJ+4LycUrh7TtGZrwKcwowUmOsop4fH4YtK2DuTREBRee3TqNnP/chxK2Rm7savYSI0fiTR+dshxTqoFuuAGnQEdge11HtUvaJ7nBVH3rqzztobgpzVdwgnbLakBHEGxWYAGmVnAcIxqhxaOluzjg5vIn5Ry1kkTr0DZfzLEH1ciEGaeKeGGhP9wfnwmRTR3ITy5ycM+bIo/cxZQjiBM3sWyzl139vlf9NDPCbdLwjROV3nYTeCZ7BGiri65f+0x57oKq57v1Aw9PVj0zRtSlWR/QGm6zMhdi2+QClpYNRJaXmN8tPr+pr3QZkNUyH0nBRZAO1pjhwkaxpwXwKX7O36hc9kBByZknJg3D0mIDNOKTxQnSuq86DB7GJFvX6GIIepryM90sTpxkVprTupGzF6oTOXThcRJzg+gVRJ0XCcJeGF9ABmPZ8/Y1m02YHFEOkZQ/k7Ge0lFY+xwy77pNJYV2DIPQks9kBk0q5j1Us2vdVNDIj4YnF80=
     
  2. The name cannot be longer than 16 characters because it's a scoreboard. Male sure that the length is max. 16 chars long
     
    • Agree Agree x 1
  3. You can use Teams prefix/suffix for another 16 chars each
     
  4. String cannot exceed 16 characters
     
  5. I managed to solve the problem, there was space in the npc name