本文整理汇总了Java中net.minecraft.scoreboard.IScoreCriteria.TRIGGER属性的典型用法代码示例。如果您正苦于以下问题:Java IScoreCriteria.TRIGGER属性的具体用法?Java IScoreCriteria.TRIGGER怎么用?Java IScoreCriteria.TRIGGER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraft.scoreboard.IScoreCriteria
的用法示例。
在下文中一共展示了IScoreCriteria.TRIGGER属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enablePlayerTrigger
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});
}
}
}
示例2: getTabCompletionOptions
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length == 1)
{
Scoreboard scoreboard = server.worldServerForDimension(0).getScoreboard();
List<String> list = Lists.<String>newArrayList();
for (ScoreObjective scoreobjective : scoreboard.getScoreObjectives())
{
if (scoreobjective.getCriteria() == IScoreCriteria.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"}): Collections.<String>emptyList();
}
}
示例3: getTabCompletionOptions
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length == 1)
{
Scoreboard scoreboard = server.worldServerForDimension(0).getScoreboard();
List<String> list = Lists.<String>newArrayList();
for (ScoreObjective scoreobjective : scoreboard.getScoreObjectives())
{
if (scoreobjective.getCriteria() == IScoreCriteria.TRIGGER)
{
list.add(scoreobjective.getName());
}
}
/**
* Returns a List of strings (chosen from the given strings) which the last word in the given string array
* is a beginning-match for. (Tab completion).
*/
return getListOfStringsMatchingLastWord(args, (String[])list.toArray(new String[list.size()]));
}
else
{
return args.length == 2 ? getListOfStringsMatchingLastWord(args, new String[] {"add", "set"}): Collections.<String>emptyList();
}
}
示例4: getTriggerNames
protected List<String> getTriggerNames(MinecraftServer server)
{
Collection<ScoreObjective> collection = this.getScoreboard(server).getScoreObjectives();
List<String> list = Lists.<String>newArrayList();
for (ScoreObjective scoreobjective : collection)
{
if (scoreobjective.getCriteria() == IScoreCriteria.TRIGGER)
{
list.add(scoreobjective.getName());
}
}
return list;
}
示例5: execute
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 3)
{
throw new WrongUsageException("commands.trigger.usage", new Object[0]);
}
else
{
EntityPlayerMP entityplayermp;
if (sender instanceof EntityPlayerMP)
{
entityplayermp = (EntityPlayerMP)sender;
}
else
{
Entity entity = sender.getCommandSenderEntity();
if (!(entity instanceof EntityPlayerMP))
{
throw new CommandException("commands.trigger.invalidPlayer", new Object[0]);
}
entityplayermp = (EntityPlayerMP)entity;
}
Scoreboard scoreboard = server.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(args[0]);
if (scoreobjective != null && scoreobjective.getCriteria() == IScoreCriteria.TRIGGER)
{
int i = parseInt(args[2]);
if (!scoreboard.entityHasObjective(entityplayermp.getName(), scoreobjective))
{
throw new CommandException("commands.trigger.invalidObjective", new Object[] {args[0]});
}
else
{
Score score = scoreboard.getOrCreateScore(entityplayermp.getName(), scoreobjective);
if (score.isLocked())
{
throw new CommandException("commands.trigger.disabled", new Object[] {args[0]});
}
else
{
if ("set".equals(args[1]))
{
score.setScorePoints(i);
}
else
{
if (!"add".equals(args[1]))
{
throw new CommandException("commands.trigger.invalidMode", new Object[] {args[1]});
}
score.increaseScore(i);
}
score.setLocked(true);
if (entityplayermp.interactionManager.isCreative())
{
notifyCommandListener(sender, this, "commands.trigger.success", new Object[] {args[0], args[1], args[2]});
}
}
}
}
else
{
throw new CommandException("commands.trigger.invalidObjective", new Object[] {args[0]});
}
}
}