I'm currently programming a Minecraft plugin and would like to modify the TabList. Can someone please send me a code to do this. I can't use links to finished plugins.
This is my previous code, but it doesn't work…
public class TabList {
public static void tabListHeaderFooter (Player player) {
String header = Main.prefix + "§e Welcome to our server!";
String footer = "§aloxDE.minecraftserver.de";
IChatBaseComponent tabHeader = new ChatMessage (header);
IChatBaseComponent tabFooter = new ChatMessage (footer);
PacketPlayOutPlayerListHeaderFooter tabPacket = new PacketPlayOutPlayerListHeaderFooter ();
try {
Field headerField = tabPacket.getClass (). GetDeclaredField ("a");
headerField.setAccessible (true);
headerField.set (tabPacket, tabHeader);
headerField.setAccessible (false);
Field footerField = tabPacket.getClass (). GetDeclaredField ("b");
footerField.setAccessible (true);
footerField.set (tabPacket, tabFooter);
footerField.setAccessible (false);
} catch (exception e) {
} finally {
((CraftPlayer) player) .getHandle (). PlayerConnection.sendPacket (tabPacket);
}
You usually take APIs for that. Your code probably still worked in 1.12? Otherwise, see if you can already use setPlayerListHeaderFooter on the player (it could be that it came later)