String playerName = args[2];
if (playerName.length() > 16) {
sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
return false;
}
Score score = objective.getScore(Bukkit.getOfflinePlayer(playerName));
int newScore;
if (args[1].equalsIgnoreCase("set")) {
newScore = value;
} else if (args[1].equalsIgnoreCase("add")) {
newScore = score.getScore() + value;
} else {
newScore = score.getScore() - value;
}
score.setScore(newScore);
sender.sendMessage("Set score of " + objectiveName + " for player " + playerName + " to " + newScore);
} else if (args[1].equalsIgnoreCase("reset")) {
if (args.length != 3) {
sender.sendMessage(ChatColor.RED + "/scoreboard players reset <player>");
return false;
}
String playerName = args[2];
if (playerName.length() > 16) {
sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
return false;
}
scoreboard.resetScores(Bukkit.getOfflinePlayer(playerName));
sender.sendMessage("Reset all scores of player " + playerName);
} else if (args[1].equalsIgnoreCase("list")) {
if (args.length > 3) {
sender.sendMessage(ChatColor.RED + "/scoreboard players list <player>");
return false;
}
if (args.length == 2) {
Set<OfflinePlayer> players = scoreboard.getPlayers();
if (players.isEmpty()) {
sender.sendMessage(ChatColor.RED + "There are no tracked players on the scoreboard");
} else {
sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + players.size() + " tracked players on the scoreboard");
sender.sendMessage(offlinePlayerSetToString(players));
}
} else {
String playerName = args[2];
if (playerName.length() > 16) {
sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
return false;
}
Set<Score> scores = scoreboard.getScores(Bukkit.getOfflinePlayer(playerName));
if (scores.isEmpty()) {
sender.sendMessage(ChatColor.RED + "Player " + playerName + " has no scores recorded");
} else {
sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + scores.size() + " tracked objective(s) for " + playerName);
for (Score score : scores) {
sender.sendMessage("- " + score.getObjective().getDisplayName() + ": " + score.getScore() + " (" + score.getObjective().getName() + ")");
}
}
}
}
} else if (args[0].equalsIgnoreCase("teams")) {