SPIGOT-456: Provide equals & hashCode methods for CraftObjective and CraftTeam

This commit is contained in:
Thinkofdeath 2015-01-25 14:39:20 +00:00
parent df17927d45
commit 4b6df5adfe
2 changed files with 42 additions and 0 deletions

View file

@ -113,4 +113,25 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
return getScoreboard(); return getScoreboard();
} }
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (this.objective != null ? this.objective.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final CraftObjective other = (CraftObjective) obj;
return !(this.objective != other.objective && (this.objective == null || !this.objective.equals(other.objective)));
}
} }

View file

@ -194,4 +194,25 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
return getScoreboard(); return getScoreboard();
} }
@Override
public int hashCode() {
int hash = 7;
hash = 43 * hash + (this.team != null ? this.team.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final CraftTeam other = (CraftTeam) obj;
return !(this.team != other.team && (this.team == null || !this.team.equals(other.team)));
}
} }