Consider arguments to team leave properly. Fixes BUKKIT-3994

Two checks to argument length were changed to properly consider if the
sender is a player instead of an off-by-one logical error.

By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
Bukkit/Spigot 2013-04-05 12:49:59 -05:00
parent 0716e7a635
commit e5dec4f10e

View file

@ -385,13 +385,13 @@ public class ScoreboardCommand extends VanillaCommand {
sender.sendMessage("Added " + addedPlayers.size() + " player(s) to team " + team.getName() + ": " + stringCollectionToString(addedPlayers));
}
} else if (args[1].equalsIgnoreCase("leave")) {
if ((sender instanceof Player) ? args.length < 2 : args.length < 3) {
if (!(sender instanceof Player) && args.length < 3) {
sender.sendMessage(ChatColor.RED + "/scoreboard teams leave [player...]");
return false;
}
Set<String> left = new HashSet<String>();
Set<String> noTeam = new HashSet<String>();
if ((sender instanceof Player) && args.length == 3) {
if ((sender instanceof Player) && args.length == 2) {
Team team = mainScoreboard.getPlayerTeam((Player) sender);
if (team != null) {
team.removePlayer((Player) sender);