| 1 | package net.minecraft.command.server;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import com.google.common.collect.Sets;
|
| 5 | import java.util.Arrays;
|
| 6 | import java.util.Collection;
|
| 7 | import java.util.List;
|
| 8 | import java.util.Map;
|
| 9 | import java.util.Set;
|
| 10 | import net.minecraft.command.CommandBase;
|
| 11 | import net.minecraft.command.CommandException;
|
| 12 | import net.minecraft.command.CommandResultStats;
|
| 13 | import net.minecraft.command.ICommandSender;
|
| 14 | import net.minecraft.command.SyntaxErrorException;
|
| 15 | import net.minecraft.command.WrongUsageException;
|
| 16 | import net.minecraft.entity.Entity;
|
| 17 | import net.minecraft.entity.player.EntityPlayer;
|
| 18 | import net.minecraft.nbt.JsonToNBT;
|
| 19 | import net.minecraft.nbt.NBTException;
|
| 20 | import net.minecraft.nbt.NBTTagCompound;
|
| 21 | import net.minecraft.nbt.NBTUtil;
|
| 22 | import net.minecraft.scoreboard.IScoreObjectiveCriteria;
|
| 23 | import net.minecraft.scoreboard.Score;
|
| 24 | import net.minecraft.scoreboard.ScoreObjective;
|
| 25 | import net.minecraft.scoreboard.ScorePlayerTeam;
|
| 26 | import net.minecraft.scoreboard.Scoreboard;
|
| 27 | import net.minecraft.scoreboard.Team;
|
| 28 | import net.minecraft.server.MinecraftServer;
|
| 29 | import net.minecraft.util.BlockPos;
|
| 30 | import net.minecraft.util.ChatComponentText;
|
| 31 | import net.minecraft.util.ChatComponentTranslation;
|
| 32 | import net.minecraft.util.EnumChatFormatting;
|
| 33 |
|
| 34 | public class CommandScoreboard extends CommandBase
|
| 35 | {
|
| 36 | /**
|
| 37 | * Gets the name of the command
|
| 38 | */
|
| 39 | public String getCommandName()
|
| 40 | {
|
| 41 | return "scoreboard";
|
| 42 | }
|
| 43 |
|
| 44 | /**
|
| 45 | * Return the required permission level for this command.
|
| 46 | */
|
| 47 | public int getRequiredPermissionLevel()
|
| 48 | {
|
| 49 | return 2;
|
| 50 | }
|
| 51 |
|
| 52 | /**
|
| 53 | * Gets the usage string for the command.
|
| 54 | */
|
| 55 | public String getCommandUsage(ICommandSender sender)
|
| 56 | {
|
| 57 | return "commands.scoreboard.usage";
|
| 58 | }
|
| 59 |
|
| 60 | /**
|
| 61 | * Callback when the command is invoked
|
| 62 | */
|
| 63 | public void processCommand(ICommandSender sender, String[] args) throws CommandException
|
| 64 | {
|
| 65 | if (!this.func_175780_b(sender, args))
|
| 66 | {
|
| 67 | if (args.length < 1)
|
| 68 | {
|
| 69 | throw new WrongUsageException("commands.scoreboard.usage", new Object[0]);
|
| 70 | }
|
| 71 | else
|
| 72 | {
|
| 73 | if (args[0].equalsIgnoreCase("objectives"))
|
| 74 | {
|
| 75 | if (args.length == 1)
|
| 76 | {
|
| 77 | throw new WrongUsageException("commands.scoreboard.objectives.usage", new Object[0]);
|
| 78 | }
|
| 79 |
|
| 80 | if (args[1].equalsIgnoreCase("list"))
|
| 81 | {
|
| 82 | this.listObjectives(sender);
|
| 83 | }
|
| 84 | else if (args[1].equalsIgnoreCase("add"))
|
| 85 | {
|
| 86 | if (args.length < 4)
|
| 87 | {
|
| 88 | throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]);
|
| 89 | }
|
| 90 |
|
| 91 | this.addObjective(sender, args, 2);
|
| 92 | }
|
| 93 | else if (args[1].equalsIgnoreCase("remove"))
|
| 94 | {
|
| 95 | if (args.length != 3)
|
| 96 | {
|
| 97 | throw new WrongUsageException("commands.scoreboard.objectives.remove.usage", new Object[0]);
|
| 98 | }
|
| 99 |
|
| 100 | this.removeObjective(sender, args[2]);
|
| 101 | }
|
| 102 | else
|
| 103 | {
|
| 104 | if (!args[1].equalsIgnoreCase("setdisplay"))
|
| 105 | {
|
| 106 | throw new WrongUsageException("commands.scoreboard.objectives.usage", new Object[0]);
|
| 107 | }
|
| 108 |
|
| 109 | if (args.length != 3 && args.length != 4)
|
| 110 | {
|
| 111 | throw new WrongUsageException("commands.scoreboard.objectives.setdisplay.usage", new Object[0]);
|
| 112 | }
|
| 113 |
|
| 114 | this.setObjectiveDisplay(sender, args, 2);
|
| 115 | }
|
| 116 | }
|
| 117 | else if (args[0].equalsIgnoreCase("players"))
|
| 118 | {
|
| 119 | if (args.length == 1)
|
| 120 | {
|
| 121 | throw new WrongUsageException("commands.scoreboard.players.usage", new Object[0]);
|
| 122 | }
|
| 123 |
|
| 124 | if (args[1].equalsIgnoreCase("list"))
|
| 125 | {
|
| 126 | if (args.length > 3)
|
| 127 | {
|
| 128 | throw new WrongUsageException("commands.scoreboard.players.list.usage", new Object[0]);
|
| 129 | }
|
| 130 |
|
| 131 | this.listPlayers(sender, args, 2);
|
| 132 | }
|
| 133 | else if (args[1].equalsIgnoreCase("add"))
|
| 134 | {
|
| 135 | if (args.length < 5)
|
| 136 | {
|
| 137 | throw new WrongUsageException("commands.scoreboard.players.add.usage", new Object[0]);
|
| 138 | }
|
| 139 |
|
| 140 | this.setPlayer(sender, args, 2);
|
| 141 | }
|
| 142 | else if (args[1].equalsIgnoreCase("remove"))
|
| 143 | {
|
| 144 | if (args.length < 5)
|
| 145 | {
|
| 146 | throw new WrongUsageException("commands.scoreboard.players.remove.usage", new Object[0]);
|
| 147 | }
|
| 148 |
|
| 149 | this.setPlayer(sender, args, 2);
|
| 150 | }
|
| 151 | else if (args[1].equalsIgnoreCase("set"))
|
| 152 | {
|
| 153 | if (args.length < 5)
|
| 154 | {
|
| 155 | throw new WrongUsageException("commands.scoreboard.players.set.usage", new Object[0]);
|
| 156 | }
|
| 157 |
|
| 158 | this.setPlayer(sender, args, 2);
|
| 159 | }
|
| 160 | else if (args[1].equalsIgnoreCase("reset"))
|
| 161 | {
|
| 162 | if (args.length != 3 && args.length != 4)
|
| 163 | {
|
| 164 | throw new WrongUsageException("commands.scoreboard.players.reset.usage", new Object[0]);
|
| 165 | }
|
| 166 |
|
| 167 | this.resetPlayers(sender, args, 2);
|
| 168 | }
|
| 169 | else if (args[1].equalsIgnoreCase("enable"))
|
| 170 | {
|
| 171 | if (args.length != 4)
|
| 172 | {
|
| 173 | throw new WrongUsageException("commands.scoreboard.players.enable.usage", new Object[0]);
|
| 174 | }
|
| 175 |
|
| 176 | this.func_175779_n(sender, args, 2);
|
| 177 | }
|
| 178 | else if (args[1].equalsIgnoreCase("test"))
|
| 179 | {
|
| 180 | if (args.length != 5 && args.length != 6)
|
| 181 | {
|
| 182 | throw new WrongUsageException("commands.scoreboard.players.test.usage", new Object[0]);
|
| 183 | }
|
| 184 |
|
| 185 | this.func_175781_o(sender, args, 2);
|
| 186 | }
|
| 187 | else
|
| 188 | {
|
| 189 | if (!args[1].equalsIgnoreCase("operation"))
|
| 190 | {
|
| 191 | throw new WrongUsageException("commands.scoreboard.players.usage", new Object[0]);
|
| 192 | }
|
| 193 |
|
| 194 | if (args.length != 7)
|
| 195 | {
|
| 196 | throw new WrongUsageException("commands.scoreboard.players.operation.usage", new Object[0]);
|
| 197 | }
|
| 198 |
|
| 199 | this.func_175778_p(sender, args, 2);
|
| 200 | }
|
| 201 | }
|
| 202 | else
|
| 203 | {
|
| 204 | if (!args[0].equalsIgnoreCase("teams"))
|
| 205 | {
|
| 206 | throw new WrongUsageException("commands.scoreboard.usage", new Object[0]);
|
| 207 | }
|
| 208 |
|
| 209 | if (args.length == 1)
|
| 210 | {
|
| 211 | throw new WrongUsageException("commands.scoreboard.teams.usage", new Object[0]);
|
| 212 | }
|
| 213 |
|
| 214 | if (args[1].equalsIgnoreCase("list"))
|
| 215 | {
|
| 216 | if (args.length > 3)
|
| 217 | {
|
| 218 | throw new WrongUsageException("commands.scoreboard.teams.list.usage", new Object[0]);
|
| 219 | }
|
| 220 |
|
| 221 | this.listTeams(sender, args, 2);
|
| 222 | }
|
| 223 | else if (args[1].equalsIgnoreCase("add"))
|
| 224 | {
|
| 225 | if (args.length < 3)
|
| 226 | {
|
| 227 | throw new WrongUsageException("commands.scoreboard.teams.add.usage", new Object[0]);
|
| 228 | }
|
| 229 |
|
| 230 | this.addTeam(sender, args, 2);
|
| 231 | }
|
| 232 | else if (args[1].equalsIgnoreCase("remove"))
|
| 233 | {
|
| 234 | if (args.length != 3)
|
| 235 | {
|
| 236 | throw new WrongUsageException("commands.scoreboard.teams.remove.usage", new Object[0]);
|
| 237 | }
|
| 238 |
|
| 239 | this.removeTeam(sender, args, 2);
|
| 240 | }
|
| 241 | else if (args[1].equalsIgnoreCase("empty"))
|
| 242 | {
|
| 243 | if (args.length != 3)
|
| 244 | {
|
| 245 | throw new WrongUsageException("commands.scoreboard.teams.empty.usage", new Object[0]);
|
| 246 | }
|
| 247 |
|
| 248 | this.emptyTeam(sender, args, 2);
|
| 249 | }
|
| 250 | else if (args[1].equalsIgnoreCase("join"))
|
| 251 | {
|
| 252 | if (args.length < 4 && (args.length != 3 || !(sender instanceof EntityPlayer)))
|
| 253 | {
|
| 254 | throw new WrongUsageException("commands.scoreboard.teams.join.usage", new Object[0]);
|
| 255 | }
|
| 256 |
|
| 257 | this.joinTeam(sender, args, 2);
|
| 258 | }
|
| 259 | else if (args[1].equalsIgnoreCase("leave"))
|
| 260 | {
|
| 261 | if (args.length < 3 && !(sender instanceof EntityPlayer))
|
| 262 | {
|
| 263 | throw new WrongUsageException("commands.scoreboard.teams.leave.usage", new Object[0]);
|
| 264 | }
|
| 265 |
|
| 266 | this.leaveTeam(sender, args, 2);
|
| 267 | }
|
| 268 | else
|
| 269 | {
|
| 270 | if (!args[1].equalsIgnoreCase("option"))
|
| 271 | {
|
| 272 | throw new WrongUsageException("commands.scoreboard.teams.usage", new Object[0]);
|
| 273 | }
|
| 274 |
|
| 275 | if (args.length != 4 && args.length != 5)
|
| 276 | {
|
| 277 | throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]);
|
| 278 | }
|
| 279 |
|
| 280 | this.setTeamOption(sender, args, 2);
|
| 281 | }
|
| 282 | }
|
| 283 | }
|
| 284 | }
|
| 285 | }
|
| 286 |
|
| 287 | private boolean func_175780_b(ICommandSender p_175780_1_, String[] p_175780_2_) throws CommandException
|
| 288 | {
|
| 289 | int i = -1;
|
| 290 |
|
| 291 | for (int j = 0; j < p_175780_2_.length; ++j)
|
| 292 | {
|
| 293 | if (this.isUsernameIndex(p_175780_2_, j) && "*".equals(p_175780_2_[j]))
|
| 294 | {
|
| 295 | if (i >= 0)
|
| 296 | {
|
| 297 | throw new CommandException("commands.scoreboard.noMultiWildcard", new Object[0]);
|
| 298 | }
|
| 299 |
|
| 300 | i = j;
|
| 301 | }
|
| 302 | }
|
| 303 |
|
| 304 | if (i < 0)
|
| 305 | {
|
| 306 | return false;
|
| 307 | }
|
| 308 | else
|
| 309 | {
|
| 310 | List<String> list1 = Lists.newArrayList(this.getScoreboard().getObjectiveNames());
|
| 311 | String s = p_175780_2_[i];
|
| 312 | List<String> list = Lists.<String>newArrayList();
|
| 313 |
|
| 314 | for (String s1 : list1)
|
| 315 | {
|
| 316 | p_175780_2_[i] = s1;
|
| 317 |
|
| 318 | try
|
| 319 | {
|
| 320 | this.processCommand(p_175780_1_, p_175780_2_);
|
| 321 | list.add(s1);
|
| 322 | }
|
| 323 | catch (CommandException commandexception)
|
| 324 | {
|
| 325 | ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(commandexception.getMessage(), commandexception.getErrorObjects());
|
| 326 | chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
|
| 327 | p_175780_1_.addChatMessage(chatcomponenttranslation);
|
| 328 | }
|
| 329 | }
|
| 330 |
|
| 331 | p_175780_2_[i] = s;
|
| 332 | p_175780_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, list.size());
|
| 333 |
|
| 334 | if (list.size() == 0)
|
| 335 | {
|
| 336 | throw new WrongUsageException("commands.scoreboard.allMatchesFailed", new Object[0]);
|
| 337 | }
|
| 338 | else
|
| 339 | {
|
| 340 | return true;
|
| 341 | }
|
| 342 | }
|
| 343 | }
|
| 344 |
|
| 345 | protected Scoreboard getScoreboard()
|
| 346 | {
|
| 347 | return MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
|
| 348 | }
|
| 349 |
|
| 350 | protected ScoreObjective getObjective(String name, boolean edit) throws CommandException
|
| 351 | {
|
| 352 | Scoreboard scoreboard = this.getScoreboard();
|
| 353 | ScoreObjective scoreobjective = scoreboard.getObjective(name);
|
| 354 |
|
| 355 | if (scoreobjective == null)
|
| 356 | {
|
| 357 | throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {name});
|
| 358 | }
|
| 359 | else if (edit && scoreobjective.getCriteria().isReadOnly())
|
| 360 | {
|
| 361 | throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {name});
|
| 362 | }
|
| 363 | else
|
| 364 | {
|
| 365 | return scoreobjective;
|
| 366 | }
|
| 367 | }
|
| 368 |
|
| 369 | protected ScorePlayerTeam getTeam(String name) throws CommandException
|
| 370 | {
|
| 371 | Scoreboard scoreboard = this.getScoreboard();
|
| 372 | ScorePlayerTeam scoreplayerteam = scoreboard.getTeam(name);
|
| 373 |
|
| 374 | if (scoreplayerteam == null)
|
| 375 | {
|
| 376 | throw new CommandException("commands.scoreboard.teamNotFound", new Object[] {name});
|
| 377 | }
|
| 378 | else
|
| 379 | {
|
| 380 | return scoreplayerteam;
|
| 381 | }
|
| 382 | }
|
| 383 |
|
| 384 | protected void addObjective(ICommandSender sender, String[] args, int index) throws CommandException
|
| 385 | {
|
| 386 | String s = args[index++];
|
| 387 | String s1 = args[index++];
|
| 388 | Scoreboard scoreboard = this.getScoreboard();
|
| 389 | IScoreObjectiveCriteria iscoreobjectivecriteria = (IScoreObjectiveCriteria)IScoreObjectiveCriteria.INSTANCES.get(s1);
|
| 390 |
|
| 391 | if (iscoreobjectivecriteria == null)
|
| 392 | {
|
| 393 | throw new WrongUsageException("commands.scoreboard.objectives.add.wrongType", new Object[] {s1});
|
| 394 | }
|
| 395 | else if (scoreboard.getObjective(s) != null)
|
| 396 | {
|
| 397 | throw new CommandException("commands.scoreboard.objectives.add.alreadyExists", new Object[] {s});
|
| 398 | }
|
| 399 | else if (s.length() > 16)
|
| 400 | {
|
| 401 | throw new SyntaxErrorException("commands.scoreboard.objectives.add.tooLong", new Object[] {s, Integer.valueOf(16)});
|
| 402 | }
|
| 403 | else if (s.length() == 0)
|
| 404 | {
|
| 405 | throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]);
|
| 406 | }
|
| 407 | else
|
| 408 | {
|
| 409 | if (args.length > index)
|
| 410 | {
|
| 411 | String s2 = getChatComponentFromNthArg(sender, args, index).getUnformattedText();
|
| 412 |
|
| 413 | if (s2.length() > 32)
|
| 414 | {
|
| 415 | throw new SyntaxErrorException("commands.scoreboard.objectives.add.displayTooLong", new Object[] {s2, Integer.valueOf(32)});
|
| 416 | }
|
| 417 |
|
| 418 | if (s2.length() > 0)
|
| 419 | {
|
| 420 | scoreboard.addScoreObjective(s, iscoreobjectivecriteria).setDisplayName(s2);
|
| 421 | }
|
| 422 | else
|
| 423 | {
|
| 424 | scoreboard.addScoreObjective(s, iscoreobjectivecriteria);
|
| 425 | }
|
| 426 | }
|
| 427 | else
|
| 428 | {
|
| 429 | scoreboard.addScoreObjective(s, iscoreobjectivecriteria);
|
| 430 | }
|
| 431 |
|
| 432 | notifyOperators(sender, this, "commands.scoreboard.objectives.add.success", new Object[] {s});
|
| 433 | }
|
| 434 | }
|
| 435 |
|
| 436 | protected void addTeam(ICommandSender sender, String[] args, int index) throws CommandException
|
| 437 | {
|
| 438 | String s = args[index++];
|
| 439 | Scoreboard scoreboard = this.getScoreboard();
|
| 440 |
|
| 441 | if (scoreboard.getTeam(s) != null)
|
| 442 | {
|
| 443 | throw new CommandException("commands.scoreboard.teams.add.alreadyExists", new Object[] {s});
|
| 444 | }
|
| 445 | else if (s.length() > 16)
|
| 446 | {
|
| 447 | throw new SyntaxErrorException("commands.scoreboard.teams.add.tooLong", new Object[] {s, Integer.valueOf(16)});
|
| 448 | }
|
| 449 | else if (s.length() == 0)
|
| 450 | {
|
| 451 | throw new WrongUsageException("commands.scoreboard.teams.add.usage", new Object[0]);
|
| 452 | }
|
| 453 | else
|
| 454 | {
|
| 455 | if (args.length > index)
|
| 456 | {
|
| 457 | String s1 = getChatComponentFromNthArg(sender, args, index).getUnformattedText();
|
| 458 |
|
| 459 | if (s1.length() > 32)
|
| 460 | {
|
| 461 | throw new SyntaxErrorException("commands.scoreboard.teams.add.displayTooLong", new Object[] {s1, Integer.valueOf(32)});
|
| 462 | }
|
| 463 |
|
| 464 | if (s1.length() > 0)
|
| 465 | {
|
| 466 | scoreboard.createTeam(s).setTeamName(s1);
|
| 467 | }
|
| 468 | else
|
| 469 | {
|
| 470 | scoreboard.createTeam(s);
|
| 471 | }
|
| 472 | }
|
| 473 | else
|
| 474 | {
|
| 475 | scoreboard.createTeam(s);
|
| 476 | }
|
| 477 |
|
| 478 | notifyOperators(sender, this, "commands.scoreboard.teams.add.success", new Object[] {s});
|
| 479 | }
|
| 480 | }
|
| 481 |
|
| 482 | protected void setTeamOption(ICommandSender sender, String[] args, int index) throws CommandException
|
| 483 | {
|
| 484 | ScorePlayerTeam scoreplayerteam = this.getTeam(args[index++]);
|
| 485 |
|
| 486 | if (scoreplayerteam != null)
|
| 487 | {
|
| 488 | String s = args[index++].toLowerCase();
|
| 489 |
|
| 490 | if (!s.equalsIgnoreCase("color") && !s.equalsIgnoreCase("friendlyfire") && !s.equalsIgnoreCase("seeFriendlyInvisibles") && !s.equalsIgnoreCase("nametagVisibility") && !s.equalsIgnoreCase("deathMessageVisibility"))
|
| 491 | {
|
| 492 | throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]);
|
| 493 | }
|
| 494 | else if (args.length == 4)
|
| 495 | {
|
| 496 | if (s.equalsIgnoreCase("color"))
|
| 497 | {
|
| 498 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(EnumChatFormatting.getValidValues(true, false))});
|
| 499 | }
|
| 500 | else if (!s.equalsIgnoreCase("friendlyfire") && !s.equalsIgnoreCase("seeFriendlyInvisibles"))
|
| 501 | {
|
| 502 | if (!s.equalsIgnoreCase("nametagVisibility") && !s.equalsIgnoreCase("deathMessageVisibility"))
|
| 503 | {
|
| 504 | throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]);
|
| 505 | }
|
| 506 | else
|
| 507 | {
|
| 508 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceString(Team.EnumVisible.func_178825_a())});
|
| 509 | }
|
| 510 | }
|
| 511 | else
|
| 512 | {
|
| 513 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(Arrays.asList(new String[]{"true", "false"}))});
|
| 514 | }
|
| 515 | }
|
| 516 | else
|
| 517 | {
|
| 518 | String s1 = args[index];
|
| 519 |
|
| 520 | if (s.equalsIgnoreCase("color"))
|
| 521 | {
|
| 522 | EnumChatFormatting enumchatformatting = EnumChatFormatting.getValueByName(s1);
|
| 523 |
|
| 524 | if (enumchatformatting == null || enumchatformatting.isFancyStyling())
|
| 525 | {
|
| 526 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(EnumChatFormatting.getValidValues(true, false))});
|
| 527 | }
|
| 528 |
|
| 529 | scoreplayerteam.setChatFormat(enumchatformatting);
|
| 530 | scoreplayerteam.setNamePrefix(enumchatformatting.toString());
|
| 531 | scoreplayerteam.setNameSuffix(EnumChatFormatting.RESET.toString());
|
| 532 | }
|
| 533 | else if (s.equalsIgnoreCase("friendlyfire"))
|
| 534 | {
|
| 535 | if (!s1.equalsIgnoreCase("true") && !s1.equalsIgnoreCase("false"))
|
| 536 | {
|
| 537 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(Arrays.asList(new String[]{"true", "false"}))});
|
| 538 | }
|
| 539 |
|
| 540 | scoreplayerteam.setAllowFriendlyFire(s1.equalsIgnoreCase("true"));
|
| 541 | }
|
| 542 | else if (s.equalsIgnoreCase("seeFriendlyInvisibles"))
|
| 543 | {
|
| 544 | if (!s1.equalsIgnoreCase("true") && !s1.equalsIgnoreCase("false"))
|
| 545 | {
|
| 546 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(Arrays.asList(new String[]{"true", "false"}))});
|
| 547 | }
|
| 548 |
|
| 549 | scoreplayerteam.setSeeFriendlyInvisiblesEnabled(s1.equalsIgnoreCase("true"));
|
| 550 | }
|
| 551 | else if (s.equalsIgnoreCase("nametagVisibility"))
|
| 552 | {
|
| 553 | Team.EnumVisible team$enumvisible = Team.EnumVisible.func_178824_a(s1);
|
| 554 |
|
| 555 | if (team$enumvisible == null)
|
| 556 | {
|
| 557 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceString(Team.EnumVisible.func_178825_a())});
|
| 558 | }
|
| 559 |
|
| 560 | scoreplayerteam.setNameTagVisibility(team$enumvisible);
|
| 561 | }
|
| 562 | else if (s.equalsIgnoreCase("deathMessageVisibility"))
|
| 563 | {
|
| 564 | Team.EnumVisible team$enumvisible1 = Team.EnumVisible.func_178824_a(s1);
|
| 565 |
|
| 566 | if (team$enumvisible1 == null)
|
| 567 | {
|
| 568 | throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceString(Team.EnumVisible.func_178825_a())});
|
| 569 | }
|
| 570 |
|
| 571 | scoreplayerteam.setDeathMessageVisibility(team$enumvisible1);
|
| 572 | }
|
| 573 |
|
| 574 | notifyOperators(sender, this, "commands.scoreboard.teams.option.success", new Object[] {s, scoreplayerteam.getRegisteredName(), s1});
|
| 575 | }
|
| 576 | }
|
| 577 | }
|
| 578 |
|
| 579 | protected void removeTeam(ICommandSender p_147194_1_, String[] p_147194_2_, int p_147194_3_) throws CommandException
|
| 580 | {
|
| 581 | Scoreboard scoreboard = this.getScoreboard();
|
| 582 | ScorePlayerTeam scoreplayerteam = this.getTeam(p_147194_2_[p_147194_3_]);
|
| 583 |
|
| 584 | if (scoreplayerteam != null)
|
| 585 | {
|
| 586 | scoreboard.removeTeam(scoreplayerteam);
|
| 587 | notifyOperators(p_147194_1_, this, "commands.scoreboard.teams.remove.success", new Object[] {scoreplayerteam.getRegisteredName()});
|
| 588 | }
|
| 589 | }
|
| 590 |
|
| 591 | protected void listTeams(ICommandSender p_147186_1_, String[] p_147186_2_, int p_147186_3_) throws CommandException
|
| 592 | {
|
| 593 | Scoreboard scoreboard = this.getScoreboard();
|
| 594 |
|
| 595 | if (p_147186_2_.length > p_147186_3_)
|
| 596 | {
|
| 597 | ScorePlayerTeam scoreplayerteam = this.getTeam(p_147186_2_[p_147186_3_]);
|
| 598 |
|
| 599 | if (scoreplayerteam == null)
|
| 600 | {
|
| 601 | return;
|
| 602 | }
|
| 603 |
|
| 604 | Collection<String> collection = scoreplayerteam.getMembershipCollection();
|
| 605 | p_147186_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());
|
| 606 |
|
| 607 | if (collection.size() <= 0)
|
| 608 | {
|
| 609 | throw new CommandException("commands.scoreboard.teams.list.player.empty", new Object[] {scoreplayerteam.getRegisteredName()});
|
| 610 | }
|
| 611 |
|
| 612 | ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.teams.list.player.count", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()});
|
| 613 | chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
|
| 614 | p_147186_1_.addChatMessage(chatcomponenttranslation);
|
| 615 | p_147186_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray())));
|
| 616 | }
|
| 617 | else
|
| 618 | {
|
| 619 | Collection<ScorePlayerTeam> collection1 = scoreboard.getTeams();
|
| 620 | p_147186_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection1.size());
|
| 621 |
|
| 622 | if (collection1.size() <= 0)
|
| 623 | {
|
| 624 | throw new CommandException("commands.scoreboard.teams.list.empty", new Object[0]);
|
| 625 | }
|
| 626 |
|
| 627 | ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.teams.list.count", new Object[] {Integer.valueOf(collection1.size())});
|
| 628 | chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
|
| 629 | p_147186_1_.addChatMessage(chatcomponenttranslation1);
|
| 630 |
|
| 631 | for (ScorePlayerTeam scoreplayerteam1 : collection1)
|
| 632 | {
|
| 633 | p_147186_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.teams.list.entry", new Object[] {scoreplayerteam1.getRegisteredName(), scoreplayerteam1.getTeamName(), Integer.valueOf(scoreplayerteam1.getMembershipCollection().size())}));
|
| 634 | }
|
| 635 | }
|
| 636 | }
|
| 637 |
|
| 638 | protected void joinTeam(ICommandSender p_147190_1_, String[] p_147190_2_, int p_147190_3_) throws CommandException
|
| 639 | {
|
| 640 | Scoreboard scoreboard = this.getScoreboard();
|
| 641 | String s = p_147190_2_[p_147190_3_++];
|
| 642 | Set<String> set = Sets.<String>newHashSet();
|
| 643 | Set<String> set1 = Sets.<String>newHashSet();
|
| 644 |
|
| 645 | if (p_147190_1_ instanceof EntityPlayer && p_147190_3_ == p_147190_2_.length)
|
| 646 | {
|
| 647 | String s4 = getCommandSenderAsPlayer(p_147190_1_).getName();
|
| 648 |
|
| 649 | if (scoreboard.addPlayerToTeam(s4, s))
|
| 650 | {
|
| 651 | set.add(s4);
|
| 652 | }
|
| 653 | else
|
| 654 | {
|
| 655 | set1.add(s4);
|
| 656 | }
|
| 657 | }
|
| 658 | else
|
| 659 | {
|
| 660 | while (p_147190_3_ < p_147190_2_.length)
|
| 661 | {
|
| 662 | String s1 = p_147190_2_[p_147190_3_++];
|
| 663 |
|
| 664 | if (s1.startsWith("@"))
|
| 665 | {
|
| 666 | for (Entity entity : func_175763_c(p_147190_1_, s1))
|
| 667 | {
|
| 668 | String s3 = getEntityName(p_147190_1_, entity.getUniqueID().toString());
|
| 669 |
|
| 670 | if (scoreboard.addPlayerToTeam(s3, s))
|
| 671 | {
|
| 672 | set.add(s3);
|
| 673 | }
|
| 674 | else
|
| 675 | {
|
| 676 | set1.add(s3);
|
| 677 | }
|
| 678 | }
|
| 679 | }
|
| 680 | else
|
| 681 | {
|
| 682 | String s2 = getEntityName(p_147190_1_, s1);
|
| 683 |
|
| 684 | if (scoreboard.addPlayerToTeam(s2, s))
|
| 685 | {
|
| 686 | set.add(s2);
|
| 687 | }
|
| 688 | else
|
| 689 | {
|
| 690 | set1.add(s2);
|
| 691 | }
|
| 692 | }
|
| 693 | }
|
| 694 | }
|
| 695 |
|
| 696 | if (!set.isEmpty())
|
| 697 | {
|
| 698 | p_147190_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, set.size());
|
| 699 | notifyOperators(p_147190_1_, this, "commands.scoreboard.teams.join.success", new Object[] {Integer.valueOf(set.size()), s, joinNiceString(set.toArray(new String[set.size()]))});
|
| 700 | }
|
| 701 |
|
| 702 | if (!set1.isEmpty())
|
| 703 | {
|
| 704 | throw new CommandException("commands.scoreboard.teams.join.failure", new Object[] {Integer.valueOf(set1.size()), s, joinNiceString(set1.toArray(new String[set1.size()]))});
|
| 705 | }
|
| 706 | }
|
| 707 |
|
| 708 | protected void leaveTeam(ICommandSender p_147199_1_, String[] p_147199_2_, int p_147199_3_) throws CommandException
|
| 709 | {
|
| 710 | Scoreboard scoreboard = this.getScoreboard();
|
| 711 | Set<String> set = Sets.<String>newHashSet();
|
| 712 | Set<String> set1 = Sets.<String>newHashSet();
|
| 713 |
|
| 714 | if (p_147199_1_ instanceof EntityPlayer && p_147199_3_ == p_147199_2_.length)
|
| 715 | {
|
| 716 | String s3 = getCommandSenderAsPlayer(p_147199_1_).getName();
|
| 717 |
|
| 718 | if (scoreboard.removePlayerFromTeams(s3))
|
| 719 | {
|
| 720 | set.add(s3);
|
| 721 | }
|
| 722 | else
|
| 723 | {
|
| 724 | set1.add(s3);
|
| 725 | }
|
| 726 | }
|
| 727 | else
|
| 728 | {
|
| 729 | while (p_147199_3_ < p_147199_2_.length)
|
| 730 | {
|
| 731 | String s = p_147199_2_[p_147199_3_++];
|
| 732 |
|
| 733 | if (s.startsWith("@"))
|
| 734 | {
|
| 735 | for (Entity entity : func_175763_c(p_147199_1_, s))
|
| 736 | {
|
| 737 | String s2 = getEntityName(p_147199_1_, entity.getUniqueID().toString());
|
| 738 |
|
| 739 | if (scoreboard.removePlayerFromTeams(s2))
|
| 740 | {
|
| 741 | set.add(s2);
|
| 742 | }
|
| 743 | else
|
| 744 | {
|
| 745 | set1.add(s2);
|
| 746 | }
|
| 747 | }
|
| 748 | }
|
| 749 | else
|
| 750 | {
|
| 751 | String s1 = getEntityName(p_147199_1_, s);
|
| 752 |
|
| 753 | if (scoreboard.removePlayerFromTeams(s1))
|
| 754 | {
|
| 755 | set.add(s1);
|
| 756 | }
|
| 757 | else
|
| 758 | {
|
| 759 | set1.add(s1);
|
| 760 | }
|
| 761 | }
|
| 762 | }
|
| 763 | }
|
| 764 |
|
| 765 | if (!set.isEmpty())
|
| 766 | {
|
| 767 | p_147199_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, set.size());
|
| 768 | notifyOperators(p_147199_1_, this, "commands.scoreboard.teams.leave.success", new Object[] {Integer.valueOf(set.size()), joinNiceString(set.toArray(new String[set.size()]))});
|
| 769 | }
|
| 770 |
|
| 771 | if (!set1.isEmpty())
|
| 772 | {
|
| 773 | throw new CommandException("commands.scoreboard.teams.leave.failure", new Object[] {Integer.valueOf(set1.size()), joinNiceString(set1.toArray(new String[set1.size()]))});
|
| 774 | }
|
| 775 | }
|
| 776 |
|
| 777 | protected void emptyTeam(ICommandSender p_147188_1_, String[] p_147188_2_, int p_147188_3_) throws CommandException
|
| 778 | {
|
| 779 | Scoreboard scoreboard = this.getScoreboard();
|
| 780 | ScorePlayerTeam scoreplayerteam = this.getTeam(p_147188_2_[p_147188_3_]);
|
| 781 |
|
| 782 | if (scoreplayerteam != null)
|
| 783 | {
|
| 784 | Collection<String> collection = Lists.newArrayList(scoreplayerteam.getMembershipCollection());
|
| 785 | p_147188_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, collection.size());
|
| 786 |
|
| 787 | if (collection.isEmpty())
|
| 788 | {
|
| 789 | throw new CommandException("commands.scoreboard.teams.empty.alreadyEmpty", new Object[] {scoreplayerteam.getRegisteredName()});
|
| 790 | }
|
| 791 | else
|
| 792 | {
|
| 793 | for (String s : collection)
|
| 794 | {
|
| 795 | scoreboard.removePlayerFromTeam(s, scoreplayerteam);
|
| 796 | }
|
| 797 |
|
| 798 | notifyOperators(p_147188_1_, this, "commands.scoreboard.teams.empty.success", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()});
|
| 799 | }
|
| 800 | }
|
| 801 | }
|
| 802 |
|
| 803 | protected void removeObjective(ICommandSender p_147191_1_, String p_147191_2_) throws CommandException
|
| 804 | {
|
| 805 | Scoreboard scoreboard = this.getScoreboard();
|
| 806 | ScoreObjective scoreobjective = this.getObjective(p_147191_2_, false);
|
| 807 | scoreboard.removeObjective(scoreobjective);
|
| 808 | notifyOperators(p_147191_1_, this, "commands.scoreboard.objectives.remove.success", new Object[] {p_147191_2_});
|
| 809 | }
|
| 810 |
|
| 811 | protected void listObjectives(ICommandSender p_147196_1_) throws CommandException
|
| 812 | {
|
| 813 | Scoreboard scoreboard = this.getScoreboard();
|
| 814 | Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();
|
| 815 |
|
| 816 | if (collection.size() <= 0)
|
| 817 | {
|
| 818 | throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
|
| 819 | }
|
| 820 | else
|
| 821 | {
|
| 822 | ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
|
| 823 | chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
|
| 824 | p_147196_1_.addChatMessage(chatcomponenttranslation);
|
| 825 |
|
| 826 | for (ScoreObjective scoreobjective : collection)
|
| 827 | {
|
| 828 | p_147196_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
|
| 829 | }
|
| 830 | }
|
| 831 | }
|
| 832 |
|
| 833 | protected void setObjectiveDisplay(ICommandSender p_147198_1_, String[] p_147198_2_, int p_147198_3_) throws CommandException
|
| 834 | {
|
| 835 | Scoreboard scoreboard = this.getScoreboard();
|
| 836 | String s = p_147198_2_[p_147198_3_++];
|
| 837 | int i = Scoreboard.getObjectiveDisplaySlotNumber(s);
|
| 838 | ScoreObjective scoreobjective = null;
|
| 839 |
|
| 840 | if (p_147198_2_.length == 4)
|
| 841 | {
|
| 842 | scoreobjective = this.getObjective(p_147198_2_[p_147198_3_], false);
|
| 843 | }
|
| 844 |
|
| 845 | if (i < 0)
|
| 846 | {
|
| 847 | throw new CommandException("commands.scoreboard.objectives.setdisplay.invalidSlot", new Object[] {s});
|
| 848 | }
|
| 849 | else
|
| 850 | {
|
| 851 | scoreboard.setObjectiveInDisplaySlot(i, scoreobjective);
|
| 852 |
|
| 853 | if (scoreobjective != null)
|
| 854 | {
|
| 855 | notifyOperators(p_147198_1_, this, "commands.scoreboard.objectives.setdisplay.successSet", new Object[] {Scoreboard.getObjectiveDisplaySlot(i), scoreobjective.getName()});
|
| 856 | }
|
| 857 | else
|
| 858 | {
|
| 859 | notifyOperators(p_147198_1_, this, "commands.scoreboard.objectives.setdisplay.successCleared", new Object[] {Scoreboard.getObjectiveDisplaySlot(i)});
|
| 860 | }
|
| 861 | }
|
| 862 | }
|
| 863 |
|
| 864 | protected void listPlayers(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) throws CommandException
|
| 865 | {
|
| 866 | Scoreboard scoreboard = this.getScoreboard();
|
| 867 |
|
| 868 | if (p_147195_2_.length > p_147195_3_)
|
| 869 | {
|
| 870 | String s = getEntityName(p_147195_1_, p_147195_2_[p_147195_3_]);
|
| 871 | Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s);
|
| 872 | p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size());
|
| 873 |
|
| 874 | if (map.size() <= 0)
|
| 875 | {
|
| 876 | throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
|
| 877 | }
|
| 878 |
|
| 879 | ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s});
|
| 880 | chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
|
| 881 | p_147195_1_.addChatMessage(chatcomponenttranslation);
|
| 882 |
|
| 883 | for (Score score : map.values())
|
| 884 | {
|
| 885 | p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()}));
|
| 886 | }
|
| 887 | }
|
| 888 | else
|
| 889 | {
|
| 890 | Collection<String> collection = scoreboard.getObjectiveNames();
|
| 891 | p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());
|
| 892 |
|
| 893 | if (collection.size() <= 0)
|
| 894 | {
|
| 895 | throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
|
| 896 | }
|
| 897 |
|
| 898 | ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())});
|
| 899 | chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
|
| 900 | p_147195_1_.addChatMessage(chatcomponenttranslation1);
|
| 901 | p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray())));
|
| 902 | }
|
| 903 | }
|
| 904 |
|
| 905 | protected void setPlayer(ICommandSender p_147197_1_, String[] p_147197_2_, int p_147197_3_) throws CommandException
|
| 906 | {
|
| 907 | String s = p_147197_2_[p_147197_3_ - 1];
|
| 908 | int i = p_147197_3_;
|
| 909 | String s1 = getEntityName(p_147197_1_, p_147197_2_[p_147197_3_++]);
|
| 910 |
|
| 911 | if (s1.length() > 40)
|
| 912 | {
|
| 913 | throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s1, Integer.valueOf(40)});
|
| 914 | }
|
| 915 | else
|
| 916 | {
|
| 917 | ScoreObjective scoreobjective = this.getObjective(p_147197_2_[p_147197_3_++], true);
|
| 918 | int j = s.equalsIgnoreCase("set") ? parseInt(p_147197_2_[p_147197_3_++]) : parseInt(p_147197_2_[p_147197_3_++], 0);
|
| 919 |
|
| 920 | if (p_147197_2_.length > p_147197_3_)
|
| 921 | {
|
| 922 | Entity entity = getEntity(p_147197_1_, p_147197_2_[i]);
|
| 923 |
|
| 924 | try
|
| 925 | {
|
| 926 | NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(buildString(p_147197_2_, p_147197_3_));
|
| 927 | NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
| 928 | entity.writeToNBT(nbttagcompound1);
|
| 929 |
|
| 930 | if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
|
| 931 | {
|
| 932 | throw new CommandException("commands.scoreboard.players.set.tagMismatch", new Object[] {s1});
|
| 933 | }
|
| 934 | }
|
| 935 | catch (NBTException nbtexception)
|
| 936 | {
|
| 937 | throw new CommandException("commands.scoreboard.players.set.tagError", new Object[] {nbtexception.getMessage()});
|
| 938 | }
|
| 939 | }
|
| 940 |
|
| 941 | Scoreboard scoreboard = this.getScoreboard();
|
| 942 | Score score = scoreboard.getValueFromObjective(s1, scoreobjective);
|
| 943 |
|
| 944 | if (s.equalsIgnoreCase("set"))
|
| 945 | {
|
| 946 | score.setScorePoints(j);
|
| 947 | }
|
| 948 | else if (s.equalsIgnoreCase("add"))
|
| 949 | {
|
| 950 | score.increseScore(j);
|
| 951 | }
|
| 952 | else
|
| 953 | {
|
| 954 | score.decreaseScore(j);
|
| 955 | }
|
| 956 |
|
| 957 | notifyOperators(p_147197_1_, this, "commands.scoreboard.players.set.success", new Object[] {scoreobjective.getName(), s1, Integer.valueOf(score.getScorePoints())});
|
| 958 | }
|
| 959 | }
|
| 960 |
|
| 961 | protected void resetPlayers(ICommandSender p_147187_1_, String[] p_147187_2_, int p_147187_3_) throws CommandException
|
| 962 | {
|
| 963 | Scoreboard scoreboard = this.getScoreboard();
|
| 964 | String s = getEntityName(p_147187_1_, p_147187_2_[p_147187_3_++]);
|
| 965 |
|
| 966 | if (p_147187_2_.length > p_147187_3_)
|
| 967 | {
|
| 968 | ScoreObjective scoreobjective = this.getObjective(p_147187_2_[p_147187_3_++], false);
|
| 969 | scoreboard.removeObjectiveFromEntity(s, scoreobjective);
|
| 970 | notifyOperators(p_147187_1_, this, "commands.scoreboard.players.resetscore.success", new Object[] {scoreobjective.getName(), s});
|
| 971 | }
|
| 972 | else
|
| 973 | {
|
| 974 | scoreboard.removeObjectiveFromEntity(s, (ScoreObjective)null);
|
| 975 | notifyOperators(p_147187_1_, this, "commands.scoreboard.players.reset.success", new Object[] {s});
|
| 976 | }
|
| 977 | }
|
| 978 |
|
| 979 | protected void func_175779_n(ICommandSender p_175779_1_, String[] p_175779_2_, int p_175779_3_) throws CommandException
|
| 980 | {
|
| 981 | Scoreboard scoreboard = this.getScoreboard();
|
| 982 | String s = getPlayerName(p_175779_1_, p_175779_2_[p_175779_3_++]);
|
| 983 |
|
| 984 | if (s.length() > 40)
|
| 985 | {
|
| 986 | throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
|
| 987 | }
|
| 988 | else
|
| 989 | {
|
| 990 | ScoreObjective scoreobjective = this.getObjective(p_175779_2_[p_175779_3_], false);
|
| 991 |
|
| 992 | if (scoreobjective.getCriteria() != IScoreObjectiveCriteria.TRIGGER)
|
| 993 | {
|
| 994 | throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
|
| 995 | }
|
| 996 | else
|
| 997 | {
|
| 998 | Score score = scoreboard.getValueFromObjective(s, scoreobjective);
|
| 999 | score.setLocked(false);
|
| 1000 | notifyOperators(p_175779_1_, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
|
| 1001 | }
|
| 1002 | }
|
| 1003 | }
|
| 1004 |
|
| 1005 | protected void func_175781_o(ICommandSender p_175781_1_, String[] p_175781_2_, int p_175781_3_) throws CommandException
|
| 1006 | {
|
| 1007 | Scoreboard scoreboard = this.getScoreboard();
|
| 1008 | String s = getEntityName(p_175781_1_, p_175781_2_[p_175781_3_++]);
|
| 1009 |
|
| 1010 | if (s.length() > 40)
|
| 1011 | {
|
| 1012 | throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
|
| 1013 | }
|
| 1014 | else
|
| 1015 | {
|
| 1016 | ScoreObjective scoreobjective = this.getObjective(p_175781_2_[p_175781_3_++], false);
|
| 1017 |
|
| 1018 | if (!scoreboard.entityHasObjective(s, scoreobjective))
|
| 1019 | {
|
| 1020 | throw new CommandException("commands.scoreboard.players.test.notFound", new Object[] {scoreobjective.getName(), s});
|
| 1021 | }
|
| 1022 | else
|
| 1023 | {
|
| 1024 | int i = p_175781_2_[p_175781_3_].equals("*") ? Integer.MIN_VALUE : parseInt(p_175781_2_[p_175781_3_]);
|
| 1025 | ++p_175781_3_;
|
| 1026 | int j = p_175781_3_ < p_175781_2_.length && !p_175781_2_[p_175781_3_].equals("*") ? parseInt(p_175781_2_[p_175781_3_], i) : Integer.MAX_VALUE;
|
| 1027 | Score score = scoreboard.getValueFromObjective(s, scoreobjective);
|
| 1028 |
|
| 1029 | if (score.getScorePoints() >= i && score.getScorePoints() <= j)
|
| 1030 | {
|
| 1031 | notifyOperators(p_175781_1_, this, "commands.scoreboard.players.test.success", new Object[] {Integer.valueOf(score.getScorePoints()), Integer.valueOf(i), Integer.valueOf(j)});
|
| 1032 | }
|
| 1033 | else
|
| 1034 | {
|
| 1035 | throw new CommandException("commands.scoreboard.players.test.failed", new Object[] {Integer.valueOf(score.getScorePoints()), Integer.valueOf(i), Integer.valueOf(j)});
|
| 1036 | }
|
| 1037 | }
|
| 1038 | }
|
| 1039 | }
|
| 1040 |
|
| 1041 | protected void func_175778_p(ICommandSender p_175778_1_, String[] p_175778_2_, int p_175778_3_) throws CommandException
|
| 1042 | {
|
| 1043 | Scoreboard scoreboard = this.getScoreboard();
|
| 1044 | String s = getEntityName(p_175778_1_, p_175778_2_[p_175778_3_++]);
|
| 1045 | ScoreObjective scoreobjective = this.getObjective(p_175778_2_[p_175778_3_++], true);
|
| 1046 | String s1 = p_175778_2_[p_175778_3_++];
|
| 1047 | String s2 = getEntityName(p_175778_1_, p_175778_2_[p_175778_3_++]);
|
| 1048 | ScoreObjective scoreobjective1 = this.getObjective(p_175778_2_[p_175778_3_], false);
|
| 1049 |
|
| 1050 | if (s.length() > 40)
|
| 1051 | {
|
| 1052 | throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
|
| 1053 | }
|
| 1054 | else if (s2.length() > 40)
|
| 1055 | {
|
| 1056 | throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s2, Integer.valueOf(40)});
|
| 1057 | }
|
| 1058 | else
|
| 1059 | {
|
| 1060 | Score score = scoreboard.getValueFromObjective(s, scoreobjective);
|
| 1061 |
|
| 1062 | if (!scoreboard.entityHasObjective(s2, scoreobjective1))
|
| 1063 | {
|
| 1064 | throw new CommandException("commands.scoreboard.players.operation.notFound", new Object[] {scoreobjective1.getName(), s2});
|
| 1065 | }
|
| 1066 | else
|
| 1067 | {
|
| 1068 | Score score1 = scoreboard.getValueFromObjective(s2, scoreobjective1);
|
| 1069 |
|
| 1070 | if (s1.equals("+="))
|
| 1071 | {
|
| 1072 | score.setScorePoints(score.getScorePoints() + score1.getScorePoints());
|
| 1073 | }
|
| 1074 | else if (s1.equals("-="))
|
| 1075 | {
|
| 1076 | score.setScorePoints(score.getScorePoints() - score1.getScorePoints());
|
| 1077 | }
|
| 1078 | else if (s1.equals("*="))
|
| 1079 | {
|
| 1080 | score.setScorePoints(score.getScorePoints() * score1.getScorePoints());
|
| 1081 | }
|
| 1082 | else if (s1.equals("/="))
|
| 1083 | {
|
| 1084 | if (score1.getScorePoints() != 0)
|
| 1085 | {
|
| 1086 | score.setScorePoints(score.getScorePoints() / score1.getScorePoints());
|
| 1087 | }
|
| 1088 | }
|
| 1089 | else if (s1.equals("%="))
|
| 1090 | {
|
| 1091 | if (score1.getScorePoints() != 0)
|
| 1092 | {
|
| 1093 | score.setScorePoints(score.getScorePoints() % score1.getScorePoints());
|
| 1094 | }
|
| 1095 | }
|
| 1096 | else if (s1.equals("="))
|
| 1097 | {
|
| 1098 | score.setScorePoints(score1.getScorePoints());
|
| 1099 | }
|
| 1100 | else if (s1.equals("<"))
|
| 1101 | {
|
| 1102 | score.setScorePoints(Math.min(score.getScorePoints(), score1.getScorePoints()));
|
| 1103 | }
|
| 1104 | else if (s1.equals(">"))
|
| 1105 | {
|
| 1106 | score.setScorePoints(Math.max(score.getScorePoints(), score1.getScorePoints()));
|
| 1107 | }
|
| 1108 | else
|
| 1109 | {
|
| 1110 | if (!s1.equals("><"))
|
| 1111 | {
|
| 1112 | throw new CommandException("commands.scoreboard.players.operation.invalidOperation", new Object[] {s1});
|
| 1113 | }
|
| 1114 |
|
| 1115 | int i = score.getScorePoints();
|
| 1116 | score.setScorePoints(score1.getScorePoints());
|
| 1117 | score1.setScorePoints(i);
|
| 1118 | }
|
| 1119 |
|
| 1120 | notifyOperators(p_175778_1_, this, "commands.scoreboard.players.operation.success", new Object[0]);
|
| 1121 | }
|
| 1122 | }
|
| 1123 | }
|
| 1124 |
|
| 1125 | public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
|
| 1126 | {
|
| 1127 | if (args.length == 1)
|
| 1128 | {
|
| 1129 | return getListOfStringsMatchingLastWord(args, new String[] {"objectives", "players", "teams"});
|
| 1130 | }
|
| 1131 | else
|
| 1132 | {
|
| 1133 | if (args[0].equalsIgnoreCase("objectives"))
|
| 1134 | {
|
| 1135 | if (args.length == 2)
|
| 1136 | {
|
| 1137 | return getListOfStringsMatchingLastWord(args, new String[] {"list", "add", "remove", "setdisplay"});
|
| 1138 | }
|
| 1139 |
|
| 1140 | if (args[1].equalsIgnoreCase("add"))
|
| 1141 | {
|
| 1142 | if (args.length == 4)
|
| 1143 | {
|
| 1144 | Set<String> set = IScoreObjectiveCriteria.INSTANCES.keySet();
|
| 1145 | return getListOfStringsMatchingLastWord(args, set);
|
| 1146 | }
|
| 1147 | }
|
| 1148 | else if (args[1].equalsIgnoreCase("remove"))
|
| 1149 | {
|
| 1150 | if (args.length == 3)
|
| 1151 | {
|
| 1152 | return getListOfStringsMatchingLastWord(args, this.func_147184_a(false));
|
| 1153 | }
|
| 1154 | }
|
| 1155 | else if (args[1].equalsIgnoreCase("setdisplay"))
|
| 1156 | {
|
| 1157 | if (args.length == 3)
|
| 1158 | {
|
| 1159 | return getListOfStringsMatchingLastWord(args, Scoreboard.getDisplaySlotStrings());
|
| 1160 | }
|
| 1161 |
|
| 1162 | if (args.length == 4)
|
| 1163 | {
|
| 1164 | return getListOfStringsMatchingLastWord(args, this.func_147184_a(false));
|
| 1165 | }
|
| 1166 | }
|
| 1167 | }
|
| 1168 | else if (args[0].equalsIgnoreCase("players"))
|
| 1169 | {
|
| 1170 | if (args.length == 2)
|
| 1171 | {
|
| 1172 | return getListOfStringsMatchingLastWord(args, new String[] {"set", "add", "remove", "reset", "list", "enable", "test", "operation"});
|
| 1173 | }
|
| 1174 |
|
| 1175 | if (!args[1].equalsIgnoreCase("set") && !args[1].equalsIgnoreCase("add") && !args[1].equalsIgnoreCase("remove") && !args[1].equalsIgnoreCase("reset"))
|
| 1176 | {
|
| 1177 | if (args[1].equalsIgnoreCase("enable"))
|
| 1178 | {
|
| 1179 | if (args.length == 3)
|
| 1180 | {
|
| 1181 | return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
| 1182 | }
|
| 1183 |
|
| 1184 | if (args.length == 4)
|
| 1185 | {
|
| 1186 | return getListOfStringsMatchingLastWord(args, this.func_175782_e());
|
| 1187 | }
|
| 1188 | }
|
| 1189 | else if (!args[1].equalsIgnoreCase("list") && !args[1].equalsIgnoreCase("test"))
|
| 1190 | {
|
| 1191 | if (args[1].equalsIgnoreCase("operation"))
|
| 1192 | {
|
| 1193 | if (args.length == 3)
|
| 1194 | {
|
| 1195 | return getListOfStringsMatchingLastWord(args, this.getScoreboard().getObjectiveNames());
|
| 1196 | }
|
| 1197 |
|
| 1198 | if (args.length == 4)
|
| 1199 | {
|
| 1200 | return getListOfStringsMatchingLastWord(args, this.func_147184_a(true));
|
| 1201 | }
|
| 1202 |
|
| 1203 | if (args.length == 5)
|
| 1204 | {
|
| 1205 | return getListOfStringsMatchingLastWord(args, new String[] {"+=", "-=", "*=", "/=", "%=", "=", "<", ">", "><"});
|
| 1206 | }
|
| 1207 |
|
| 1208 | if (args.length == 6)
|
| 1209 | {
|
| 1210 | return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
| 1211 | }
|
| 1212 |
|
| 1213 | if (args.length == 7)
|
| 1214 | {
|
| 1215 | return getListOfStringsMatchingLastWord(args, this.func_147184_a(false));
|
| 1216 | }
|
| 1217 | }
|
| 1218 | }
|
| 1219 | else
|
| 1220 | {
|
| 1221 | if (args.length == 3)
|
| 1222 | {
|
| 1223 | return getListOfStringsMatchingLastWord(args, this.getScoreboard().getObjectiveNames());
|
| 1224 | }
|
| 1225 |
|
| 1226 | if (args.length == 4 && args[1].equalsIgnoreCase("test"))
|
| 1227 | {
|
| 1228 | return getListOfStringsMatchingLastWord(args, this.func_147184_a(false));
|
| 1229 | }
|
| 1230 | }
|
| 1231 | }
|
| 1232 | else
|
| 1233 | {
|
| 1234 | if (args.length == 3)
|
| 1235 | {
|
| 1236 | return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
| 1237 | }
|
| 1238 |
|
| 1239 | if (args.length == 4)
|
| 1240 | {
|
| 1241 | return getListOfStringsMatchingLastWord(args, this.func_147184_a(true));
|
| 1242 | }
|
| 1243 | }
|
| 1244 | }
|
| 1245 | else if (args[0].equalsIgnoreCase("teams"))
|
| 1246 | {
|
| 1247 | if (args.length == 2)
|
| 1248 | {
|
| 1249 | return getListOfStringsMatchingLastWord(args, new String[] {"add", "remove", "join", "leave", "empty", "list", "option"});
|
| 1250 | }
|
| 1251 |
|
| 1252 | if (args[1].equalsIgnoreCase("join"))
|
| 1253 | {
|
| 1254 | if (args.length == 3)
|
| 1255 | {
|
| 1256 | return getListOfStringsMatchingLastWord(args, this.getScoreboard().getTeamNames());
|
| 1257 | }
|
| 1258 |
|
| 1259 | if (args.length >= 4)
|
| 1260 | {
|
| 1261 | return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
| 1262 | }
|
| 1263 | }
|
| 1264 | else
|
| 1265 | {
|
| 1266 | if (args[1].equalsIgnoreCase("leave"))
|
| 1267 | {
|
| 1268 | return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
| 1269 | }
|
| 1270 |
|
| 1271 | if (!args[1].equalsIgnoreCase("empty") && !args[1].equalsIgnoreCase("list") && !args[1].equalsIgnoreCase("remove"))
|
| 1272 | {
|
| 1273 | if (args[1].equalsIgnoreCase("option"))
|
| 1274 | {
|
| 1275 | if (args.length == 3)
|
| 1276 | {
|
| 1277 | return getListOfStringsMatchingLastWord(args, this.getScoreboard().getTeamNames());
|
| 1278 | }
|
| 1279 |
|
| 1280 | if (args.length == 4)
|
| 1281 | {
|
| 1282 | return getListOfStringsMatchingLastWord(args, new String[] {"color", "friendlyfire", "seeFriendlyInvisibles", "nametagVisibility", "deathMessageVisibility"});
|
| 1283 | }
|
| 1284 |
|
| 1285 | if (args.length == 5)
|
| 1286 | {
|
| 1287 | if (args[3].equalsIgnoreCase("color"))
|
| 1288 | {
|
| 1289 | return getListOfStringsMatchingLastWord(args, EnumChatFormatting.getValidValues(true, false));
|
| 1290 | }
|
| 1291 |
|
| 1292 | if (args[3].equalsIgnoreCase("nametagVisibility") || args[3].equalsIgnoreCase("deathMessageVisibility"))
|
| 1293 | {
|
| 1294 | return getListOfStringsMatchingLastWord(args, Team.EnumVisible.func_178825_a());
|
| 1295 | }
|
| 1296 |
|
| 1297 | if (args[3].equalsIgnoreCase("friendlyfire") || args[3].equalsIgnoreCase("seeFriendlyInvisibles"))
|
| 1298 | {
|
| 1299 | return getListOfStringsMatchingLastWord(args, new String[] {"true", "false"});
|
| 1300 | }
|
| 1301 | }
|
| 1302 | }
|
| 1303 | }
|
| 1304 | else if (args.length == 3)
|
| 1305 | {
|
| 1306 | return getListOfStringsMatchingLastWord(args, this.getScoreboard().getTeamNames());
|
| 1307 | }
|
| 1308 | }
|
| 1309 | }
|
| 1310 |
|
| 1311 | return null;
|
| 1312 | }
|
| 1313 | }
|
| 1314 |
|
| 1315 | protected List<String> func_147184_a(boolean p_147184_1_)
|
| 1316 | {
|
| 1317 | Collection<ScoreObjective> collection = this.getScoreboard().getScoreObjectives();
|
| 1318 | List<String> list = Lists.<String>newArrayList();
|
| 1319 |
|
| 1320 | for (ScoreObjective scoreobjective : collection)
|
| 1321 | {
|
| 1322 | if (!p_147184_1_ || !scoreobjective.getCriteria().isReadOnly())
|
| 1323 | {
|
| 1324 | list.add(scoreobjective.getName());
|
| 1325 | }
|
| 1326 | }
|
| 1327 |
|
| 1328 | return list;
|
| 1329 | }
|
| 1330 |
|
| 1331 | protected List<String> func_175782_e()
|
| 1332 | {
|
| 1333 | Collection<ScoreObjective> collection = this.getScoreboard().getScoreObjectives();
|
| 1334 | List<String> list = Lists.<String>newArrayList();
|
| 1335 |
|
| 1336 | for (ScoreObjective scoreobjective : collection)
|
| 1337 | {
|
| 1338 | if (scoreobjective.getCriteria() == IScoreObjectiveCriteria.TRIGGER)
|
| 1339 | {
|
| 1340 | list.add(scoreobjective.getName());
|
| 1341 | }
|
| 1342 | }
|
| 1343 |
|
| 1344 | return list;
|
| 1345 | }
|
| 1346 |
|
| 1347 | /**
|
| 1348 | * Return whether the specified command parameter index is a username parameter.
|
| 1349 | */
|
| 1350 | public boolean isUsernameIndex(String[] args, int index)
|
| 1351 | {
|
| 1352 | return !args[0].equalsIgnoreCase("players") ? (args[0].equalsIgnoreCase("teams") ? index == 2 : false) : (args.length > 1 && args[1].equalsIgnoreCase("operation") ? index == 2 || index == 5 : index == 2);
|
| 1353 | }
|
| 1354 | }
|
| 1355 |
|