本文整理汇总了Java中net.minecraft.scoreboard.Scoreboard.getObjectiveNames方法的典型用法代码示例。如果您正苦于以下问题:Java Scoreboard.getObjectiveNames方法的具体用法?Java Scoreboard.getObjectiveNames怎么用?Java Scoreboard.getObjectiveNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.scoreboard.Scoreboard
的用法示例。
在下文中一共展示了Scoreboard.getObjectiveNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listPlayers
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void listPlayers(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
if (p_147195_2_.length > p_147195_3_)
{
String s = getEntityName(p_147195_1_, p_147195_2_[p_147195_3_]);
Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s);
p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size());
if (map.size() <= 0)
{
throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
}
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
p_147195_1_.addChatMessage(chatcomponenttranslation);
for (Score score : map.values())
{
p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()}));
}
}
else
{
Collection<String> collection = scoreboard.getObjectiveNames();
p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());
if (collection.size() <= 0)
{
throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
}
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())});
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
p_147195_1_.addChatMessage(chatcomponenttranslation1);
p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray())));
}
}
示例2: listPlayers
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void listPlayers(ICommandSender sender, String[] p_184920_2_, int p_184920_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
if (p_184920_2_.length > p_184920_3_)
{
String s = getEntityName(server, sender, p_184920_2_[p_184920_3_]);
Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s);
sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size());
if (map.isEmpty())
{
throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
}
TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s});
textcomponenttranslation.getStyle().setColor(TextFormatting.DARK_GREEN);
sender.addChatMessage(textcomponenttranslation);
for (Score score : map.values())
{
sender.addChatMessage(new TextComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()}));
}
}
else
{
Collection<String> collection = scoreboard.getObjectiveNames();
sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());
if (collection.isEmpty())
{
throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
}
TextComponentTranslation textcomponenttranslation1 = new TextComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())});
textcomponenttranslation1.getStyle().setColor(TextFormatting.DARK_GREEN);
sender.addChatMessage(textcomponenttranslation1);
sender.addChatMessage(new TextComponentString(joinNiceString(collection.toArray())));
}
}