Bukkit Support (Please Look)

Status
This thread has been locked.

Function

Minecraft Plugin Developer
Supreme
Feedback score
38
Posts
938
Reactions
332
Resources
0
I have the code
Code:
public void setupTab() {
        final PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();

        new BukkitRunnable() {
            @Override
            public void run() {
                try {
                    Field a = packet.getClass().getDeclaredField("a");
                    Field b = packet.getClass().getDeclaredField("b");

                    a.setAccessible(true);
                    b.setAccessible(true);

                    Object header = new ChatComponentText(ChatColor.RED + "" + ChatColor.BOLD + "SERVER " + ChatColor.GRAY + "("+Bukkit.getServer().getOnlinePlayers().size()+"/"+Bukkit.getServer().getMaxPlayers()+")");

                    String tpsString;

                    DecimalFormat decimalFormat = new DecimalFormat("##.00");

                    double tps = Bukkit.spigot().getTPS()[0];
                    if(tps > 20) {
                        tpsString = ChatColor.GREEN + "*20.00";
                    } else {
                        tpsString = decimalFormat.format(Bukkit.spigot().getTPS()[0]);
                    }

                    Object footer = new ChatComponentText(ChatColor.GRAY + "" + ChatColor.ITALIC + "Running at "+tpsString+ ChatColor.GRAY + "tps " + "\n\n"+ChatColor.RED + "Purchase ranks and perks at buy.shop.com");

                    a.set(packet, header);
                    b.set(packet, footer);

                    for (Player player : Bukkit.getOnlinePlayers()) {
                        player.setPlayerListName(ChatColor.translateAlternateColorCodes('&', TabPrefix.translate(Vault.getPermissions().getPrimaryGroup(player)) + player.getName()));
                        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
                    }
                } catch (NoSuchFieldException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }.runTaskTimer(this, 0, 20);
    }
and I was wondering how could I sort the player names by there rank. Is this possible this way?
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Function

Minecraft Plugin Developer
Supreme
Feedback score
38
Posts
938
Reactions
332
Resources
0
Plenty of ways. Scoreboard teams, is what comes to mind pretty quickly.
But, how would I that is this situation? Would it be the same way?
 
Status
This thread has been locked.
Top