Fixed Scoreboard for Minecraft v.13.x Bukkit

Nov 7, 2018
Fixed Scoreboard for Minecraft v.13.x Bukkit
  • Hello guys,
    today I fixed my Scoreboard for v.13.x. I'd like to share it with you, because I had to figure out how to get the declaredfield("b"). It doesn't work anymore for me. Here is my solution:

    Code (Text):
        public <CraftPlayer> void sendTablistHeaderAndFooter(Player p, String header, String footer) {
            if(header == null) header = "";
            if(footer == null) footer = "";
         
            IChatBaseComponent tabHeader = ChatSerializer.a("{\"text\":\"" + header + "\"}");
            IChatBaseComponent tabFooter = ChatSerializer.a("{\"text\":\"" + footer + "\"}");
         
            PacketPlayOutPlayerListHeaderFooter headerPacket = new PacketPlayOutPlayerListHeaderFooter();
            PacketPlayOutPlayerListHeaderFooter footerPacket = new PacketPlayOutPlayerListHeaderFooter();
            try {
                Field[] header1 = headerPacket.getClass().getDeclaredFields();
                header1[0].setAccessible(true);
                header1[0].set(headerPacket, tabHeader);
             
                Field[] header2 = headerPacket.getClass().getDeclaredFields();
                header2[1].setAccessible(true);
                header2[1].set(headerPacket, tabFooter);
             
                ((org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)p).getHandle().playerConnection.sendPacket(headerPacket);
             
                Field[] header3 = footerPacket.getClass().getDeclaredFields();
                header3[0].setAccessible(true);
                header3[0].set(footerPacket, tabHeader);
             
                Field[] header4 = footerPacket.getClass().getDeclaredFields();
                header4[1].setAccessible(true);
                header4[1].set(footerPacket, tabHeader);
             
                ((org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)p).getHandle().playerConnection.sendPacket(headerPacket);
                // ((org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)p).getHandle().playerConnection.sendPacket(footerPacket);
            } catch(Exception e) {
                e.printStackTrace();
            }finally{
            }
        }
    }    
  • Loading...
  • Loading...