Name above head

Discussion in 'Spigot Plugin Development' started by TostiTegen, Jun 1, 2018.

  1. Does someone know why I get every time kicked for a name longer than 16 characters with this test code 'Creative'


    Code (Text):
      public static void changeName(String name, Player player) {
            try {
                Method getHandle = player.getClass().getMethod("getHandle", (Class<?>[]) null);
                Object entityPlayer = getHandle.invoke(player);
                Class<?> entityHuman = entityPlayer.getClass().getSuperclass();
                Field bH = entityHuman.getDeclaredField("bH");
                bH.setAccessible(true);
                bH.set(entityPlayer, new GameProfile(player.getUniqueId(), "Creative"));
                for (Player players : Bukkit.getOnlinePlayers()) {
                    players.hidePlayer(player);
                    players.showPlayer(player);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
     
  2. 16 characters is the max unfortunately iirc
     
  3. Please could you tell me if this is 16 characters: "Creative"
    Code (Text):
           bH.set(entityPlayer, new GameProfile(player.getUniqueId(), "Creative"));
     
  4. Any Prefix and Suffixes? I had difficulties where they where counted to the 16 char limit
     
  5. This is litterly my whole code I have no scoreboards, tab or other things in my server.