Java 类net.minecraft.server.PacketPlayOutScoreboardTeam 实例源码

项目:ProjectAres    文件:NMSHacks.java   
public static Packet teamPacket(int operation,
                                String name,
                                String displayName,
                                String prefix,
                                String suffix,
                                boolean friendlyFire,
                                boolean seeFriendlyInvisibles,
                                String nameTagVisibility,
                                String collisionRule,
                                Collection<String> players) {

    int flags = 0;
    if(friendlyFire) { flags |= 1; }
    if(seeFriendlyInvisibles) { flags |= 2; }

    return new PacketPlayOutScoreboardTeam(operation,
                                           name, displayName, prefix, suffix,
                                           0, // color
                                           nameTagVisibility,
                                           collisionRule,
                                           flags,
                                           players);
}
项目:CardinalPGM    文件:TabList.java   
public static Packet getTeamPacket(Collection<String> players, int slot, int action) {
    String team = "\000TabView" + (slot < 10 ? "0" + slot : slot);
    return new PacketPlayOutScoreboardTeam(action, team, team, "", "", -1, "never", "never", 0, players);
}
项目:CardinalPGM    文件:Stats.java   
private void sendTeamPackets(Player player, boolean set) {
    String prefix = "K:" + ChatColor.GREEN + "0";
    String suffix = "0" + ChatColor.WHITE + " K/D:" + ChatColor.AQUA + "0.00";
    PacketUtils.sendPacket(player, new PacketPlayOutScoreboardTeam(set ? 0 : 1, "scoreboard-stats", "scoreboard-stats", prefix, suffix, -1, "never", "never", 0, Collections.singletonList(scoreboardEntry)));
}
项目:CardinalPGM    文件:Stats.java   
public void updateDisplay(final Player player) {
    if (!shouldShow(player)) return;

    final int kills = getKills(player.getUniqueId());
    final int deaths = getDeaths(player.getUniqueId());
    final String kd = format.format((double)kills / Math.max(deaths, 1)).replace(",", ".");

    switch (Settings.getSettingByName("Stats").getValueByPlayer(player).getValue()) {
        case "sidebar":
            if (!sidebarView.contains(player.getUniqueId())) {
                sidebarView.add(player.getUniqueId());
                sendTeamPackets(player, true);
            }
            sendSlotPackets(player, true);
            String prefix = "K:" + ChatColor.GREEN + Math.min(kills, 999);
            String suffix = "" + Math.min(deaths, 999) + ChatColor.WHITE + " K/D:" + ChatColor.AQUA + kd;
            PacketUtils.sendPacket(player, new PacketPlayOutScoreboardTeam(2, "scoreboard-stats", "scoreboard-stats", prefix, suffix, -1, "never", "never", 0, Collections.singletonList(scoreboardEntry)));
            break;
        case "boss bar":
            if (!bossBars.containsKey(player.getUniqueId())) {
                LocalizedBossBar bossBar = new LocalizedBossBar(new UnlocalizedChatMessage(""), BarColor.PURPLE, BarStyle.SOLID);
                bossBar.addPlayer(player);
                bossBars.put(player.getUniqueId(), bossBar);
            }
            bossBars.get(player.getUniqueId()).setTitle(getLocalizedMessage(kills, deaths, kd));
            break;
        case "action bar":
            if (actionBarTasks.containsKey(player.getUniqueId())) {
                Bukkit.getScheduler().cancelTask(actionBarTasks.get(player.getUniqueId()));
            }
            actionBarTasks.put(player.getUniqueId(), Bukkit.getScheduler().scheduleSyncRepeatingTask(Cardinal.getInstance(), new Runnable() {

                private int tick;

                @Override
                public void run() {
                    if (tick > 40) {
                        if (actionBarTasks.containsKey(player.getUniqueId())) {
                            Bukkit.getScheduler().cancelTask(actionBarTasks.get(player.getUniqueId()));
                            actionBarTasks.remove(player.getUniqueId());
                        }
                    } else {
                        sendActionBarPacket(player, kills, deaths, kd);
                        tick++;
                    }
                }
            }, 1L, 1L));
            break;
    }
}