本文整理汇总了Java中net.minecraft.scoreboard.Scoreboard类的典型用法代码示例。如果您正苦于以下问题:Java Scoreboard类的具体用法?Java Scoreboard怎么用?Java Scoreboard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scoreboard类属于net.minecraft.scoreboard包,在下文中一共展示了Scoreboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetPlayerScore
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void resetPlayerScore(ICommandSender sender, String[] p_184912_2_, int p_184912_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
String s = getEntityName(server, sender, p_184912_2_[p_184912_3_++]);
if (p_184912_2_.length > p_184912_3_)
{
ScoreObjective scoreobjective = this.convertToObjective(p_184912_2_[p_184912_3_++], false, server);
scoreboard.removeObjectiveFromEntity(s, scoreobjective);
notifyCommandListener(sender, this, "commands.scoreboard.players.resetscore.success", new Object[] {scoreobjective.getName(), s});
}
else
{
scoreboard.removeObjectiveFromEntity(s, (ScoreObjective)null);
notifyCommandListener(sender, this, "commands.scoreboard.players.reset.success", new Object[] {s});
}
}
示例2: emptyTeam
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void emptyTeam(ICommandSender sender, String[] p_184917_2_, int p_184917_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
ScorePlayerTeam scoreplayerteam = this.convertToTeam(p_184917_2_[p_184917_3_], server);
if (scoreplayerteam != null)
{
Collection<String> collection = Lists.newArrayList(scoreplayerteam.getMembershipCollection());
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, collection.size());
if (collection.isEmpty())
{
throw new CommandException("commands.scoreboard.teams.empty.alreadyEmpty", new Object[] {scoreplayerteam.getRegisteredName()});
}
else
{
for (String s : collection)
{
scoreboard.removePlayerFromTeam(s, scoreplayerteam);
}
notifyCommandListener(sender, this, "commands.scoreboard.teams.empty.success", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()});
}
}
}
示例3: getObjective
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected ScoreObjective getObjective(String name, boolean edit) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(name);
if (scoreobjective == null)
{
throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {name});
}
else if (edit && scoreobjective.getCriteria().isReadOnly())
{
throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {name});
}
else
{
return scoreobjective;
}
}
示例4: handleUpdateScore
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an objective
*/
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例5: emptyTeam
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void emptyTeam(ICommandSender p_147188_1_, String[] p_147188_2_, int p_147188_3_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
ScorePlayerTeam scoreplayerteam = this.getTeam(p_147188_2_[p_147188_3_]);
if (scoreplayerteam != null)
{
Collection<String> collection = Lists.newArrayList(scoreplayerteam.getMembershipCollection());
p_147188_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, collection.size());
if (collection.isEmpty())
{
throw new CommandException("commands.scoreboard.teams.empty.alreadyEmpty", new Object[] {scoreplayerteam.getRegisteredName()});
}
else
{
for (String s : collection)
{
scoreboard.removePlayerFromTeam(s, scoreplayerteam);
}
notifyOperators(p_147188_1_, this, "commands.scoreboard.teams.empty.success", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()});
}
}
}
示例6: func_175779_n
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void func_175779_n(ICommandSender p_175779_1_, String[] p_175779_2_, int p_175779_3_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
String s = getPlayerName(p_175779_1_, p_175779_2_[p_175779_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.getObjective(p_175779_2_[p_175779_3_], false);
if (scoreobjective.getCriteria() != IScoreObjectiveCriteria.TRIGGER)
{
throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
}
else
{
Score score = scoreboard.getValueFromObjective(s, scoreobjective);
score.setLocked(false);
notifyOperators(p_175779_1_, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
}
}
}
示例7: addTabCompletionOptions
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
Scoreboard scoreboard = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
List<String> list = Lists.<String>newArrayList();
for (ScoreObjective scoreobjective : scoreboard.getScoreObjectives())
{
if (scoreobjective.getCriteria() == IScoreObjectiveCriteria.TRIGGER)
{
list.add(scoreobjective.getName());
}
}
return getListOfStringsMatchingLastWord(args, (String[])list.toArray(new String[list.size()]));
}
else
{
return args.length == 2 ? getListOfStringsMatchingLastWord(args, new String[] {"add", "set"}): null;
}
}
示例8: handleRespawn
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
public void handleRespawn(S07PacketRespawn packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if (packetIn.getDimensionID() != this.gameController.thePlayer.dimension)
{
this.doneLoadingTerrain = false;
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler);
this.clientWorldController.setWorldScoreboard(scoreboard);
this.gameController.loadWorld(this.clientWorldController);
this.gameController.thePlayer.dimension = packetIn.getDimensionID();
this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
}
this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID());
this.gameController.playerController.setGameType(packetIn.getGameType());
}
示例9: handleUpdateScore
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an objective
*/
public void handleUpdateScore(S3CPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例10: handleDisplayScoreboard
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
/**
* Removes or sets the ScoreObjective to be displayed at a particular scoreboard position (list, sidebar, below
* name)
*/
public void handleDisplayScoreboard(S3DPacketDisplayScoreboard packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.func_149370_d().length() == 0)
{
scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), (ScoreObjective)null);
}
else
{
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.func_149370_d());
scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), scoreobjective);
}
}
示例11: getUnformattedTextForChat
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
/**
* Gets the text of this component, without any special formatting codes added, for chat. TODO: why is this two
* different methods?
*/
public String getUnformattedTextForChat()
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
{
Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);
if (scoreboard.entityHasObjective(this.name, scoreobjective))
{
Score score = scoreboard.getValueFromObjective(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
}
else
{
this.value = "";
}
}
return this.value;
}
示例12: enablePlayerTrigger
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.convertToObjective(p_184914_2_[p_184914_3_], false, server);
if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
{
throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
}
else
{
Score score = scoreboard.getOrCreateScore(s, scoreobjective);
score.setLocked(false);
notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
}
}
}
示例13: resolve
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
public void resolve(ICommandSender sender)
{
MinecraftServer minecraftserver = sender.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
{
Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);
if (scoreboard.entityHasObjective(this.name, scoreobjective))
{
Score score = scoreboard.getOrCreateScore(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
}
else
{
this.value = "";
}
}
}
示例14: listObjectives
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void listObjectives(ICommandSender p_147196_1_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();
if (collection.size() <= 0)
{
throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
}
else
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
p_147196_1_.addChatMessage(chatcomponenttranslation);
for (ScoreObjective scoreobjective : collection)
{
p_147196_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
}
}
}
示例15: renderEntityName
import net.minecraft.scoreboard.Scoreboard; //导入依赖的package包/类
protected void renderEntityName(AbstractClientPlayer entityIn, double x, double y, double z, String name, double distanceSq)
{
if (distanceSq < 100.0D)
{
Scoreboard scoreboard = entityIn.getWorldScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2);
if (scoreobjective != null)
{
Score score = scoreboard.getOrCreateScore(entityIn.getName(), scoreobjective);
this.renderLivingLabel(entityIn, score.getScorePoints() + " " + scoreobjective.getDisplayName(), x, y, z, 64);
y += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F);
}
}
super.renderEntityName(entityIn, x, y, z, name, distanceSq);
}