Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void sendTablist(Player p, String header, String footer) {
- if (header == null)
- header = "";
- if (footer == null)
- footer = "";
- header = ChatColor.translateAlternateColorCodes('&', header);
- footer = ChatColor.translateAlternateColorCodes('&', footer);
- header = header.replaceAll("%PLAYER%", p.getDisplayName());
- footer = footer.replaceAll("%PLAYER%", p.getDisplayName());
- PlayerConnection con = ((CraftPlayer) p).getHandle().playerConnection;
- IChatBaseComponent tabheader = ChatSerializer.a("{\"text\": \""
- + header + "\"}");
- IChatBaseComponent tabfooter = ChatSerializer.a("{\"text\": \""
- + footer + "\"}");
- PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(
- tabheader);
- try {
- Field f = packet.getClass().getDeclaredField("b");
- f.setAccessible(true);
- f.set(packet, tabfooter);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- con.sendPacket(packet);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement