correctName = p.getName().equals(playerName);
}
}
// check if the team is correct if specified
Scoreboard board = p.get(Scoreboard.class);
boolean correctTeam = teamName == null; // default to whether the team name is set
if (teamName != null && board != null) {
Team team = board.getTeam(teamName);
if (team != null) {
if (teamNameInverted) {
// make sure the player is not on the specified team
correctTeam = !team.getPlayerNames().contains(p.getName());
} else {
// make sure the player is on the specified team
correctTeam = team.getPlayerNames().contains(p.getName());
}
}
}
// make sure the player has the right amount of points for the specified objectives
boolean enoughPoints = minScores.isEmpty() && maxScores.isEmpty(); // default to whether there are any objectives set
if (board != null) {
// first make sure the player has the minimum requirements
for (Map.Entry<String, Integer> e : minScores.entrySet()) {
Objective obj = board.getObjective(e.getKey());
if (obj == null) {
continue;
}
int score = obj.getScore(p.getName()); // player's score for specified objective
int minScore = e.getValue(); // specified minimum score
enoughPoints = score >= minScore;
if (!enoughPoints) {
// not enough? break.
break;
}
}
// next make sure the player isn't over the maximums
for (Map.Entry<String, Integer> e : maxScores.entrySet()) {
Objective obj = board.getObjective(e.getKey());
if (obj == null) {
continue;
}
int score = obj.getScore(p.getName()); // player's score for specified objective