How do I make a Spigot 1649 Header / Footer tab list plugin?

Discussion in 'Spigot Plugin Development' started by GetRektRight, May 25, 2015.

  1. I have searched everywhere to figure out how to make a Header / Footer tab list plugins for Spigot 1649, but I seem to keep failing to find what I search for. If someone could please give me a step by step tutorial on how to do this, it would be great. Thanks!
     
  2. Here you are :) header and footer can contain \n to build a multi-line header/footer! Have fun!

    Code (Text):
    package net.friwi.util.tablist;

    import java.lang.reflect.Field;

    import net.minecraft.server.v1_8_R2.IChatBaseComponent;
    import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerListHeaderFooter;
    import net.minecraft.server.v1_8_R2.PlayerConnection;

    import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
    import org.bukkit.entity.Player;

    public class TablistUtil {
        public static void setForPlayer(Player p, String header, String footer){
           
            CraftPlayer craftplayer = (CraftPlayer)p;
            PlayerConnection connection = craftplayer.getHandle().playerConnection;
            IChatBaseComponent top = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + header + "\"}");
            IChatBaseComponent bottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + footer + "\"}");

            PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
            try
            {
              Field headerField = packet.getClass().getDeclaredField("a");
              headerField.setAccessible(true);
              headerField.set(packet, top);
              headerField.setAccessible(!headerField.isAccessible());

              Field footerField = packet.getClass().getDeclaredField("b");
              footerField.setAccessible(true);
              footerField.set(packet, bottom);
              footerField.setAccessible(!footerField.isAccessible());
            } catch (Exception ev) {
              ev.printStackTrace();
            }

            connection.sendPacket(packet);
        }
    }
     
  3. How do I make the plugin.yml?
     
  4. joehot200

    Supporter

    Just make a text file:

    [​IMG]

    Code (Text):

    name: AntiAura #The name of the plugin goes here
    main: a.g #Your main class goes here
    version: 5.05 #The version of the plugin goes here
    depend: [ProtocolLib] #Any dependencies go here
    commands:
        silence: #Any commands go here
     
     
  5. Okay, one final question. What do I import for it to work for Spigot 1649?
     
  6. Code (Text):
    import java.lang.reflect.Field;

    import net.minecraft.server.v1_7_R4.IChatBaseComponent;
    import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerListHeaderFooter;
    import net.minecraft.server.v1_7_R4.PlayerConnection;

    import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
    import org.bukkit.entity.Player;