Made OfflinePlayer and Player share the same .equals and .hashcode

This commit is contained in:
Nathan Adams
2011-12-12 15:34:49 +00:00
parent 82965eb10f
commit 91ff0b059d
2 changed files with 27 additions and 5 deletions

View File

@@ -97,4 +97,26 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
return null;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof OfflinePlayer)) {
return false;
}
OfflinePlayer other = (OfflinePlayer)obj;
if ((this.getName() == null) || (other.getName() == null)) {
return false;
}
return this.getName().equalsIgnoreCase(other.getName());
}
@Override
public int hashCode() {
int hash = 5;
hash = 97 * hash + (this.getName() != null ? this.getName().hashCode() : 0);
return hash;
}
}