本文整理汇总了Java中net.minecraft.server.PacketPlayOutScoreboardTeam类的典型用法代码示例。如果您正苦于以下问题:Java PacketPlayOutScoreboardTeam类的具体用法?Java PacketPlayOutScoreboardTeam怎么用?Java PacketPlayOutScoreboardTeam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketPlayOutScoreboardTeam类属于net.minecraft.server包,在下文中一共展示了PacketPlayOutScoreboardTeam类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: teamPacket
import net.minecraft.server.PacketPlayOutScoreboardTeam; //导入依赖的package包/类
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);
}
示例2: updateDisplay
import net.minecraft.server.PacketPlayOutScoreboardTeam; //导入依赖的package包/类
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;
}
}
示例3: getTeamPacket
import net.minecraft.server.PacketPlayOutScoreboardTeam; //导入依赖的package包/类
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);
}
示例4: sendTeamPackets
import net.minecraft.server.PacketPlayOutScoreboardTeam; //导入依赖的package包/类
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)));
}