mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
Use UUIDs in CraftPlayer equals and hashCode methods. Fixes BUKKIT-5634
This commit is contained in:
parent
38fbe60d46
commit
0a45c3ebf7
@ -222,18 +222,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return false;
|
||||
}
|
||||
OfflinePlayer other = (OfflinePlayer) obj;
|
||||
if ((this.getName() == null) || (other.getName() == null)) {
|
||||
if ((this.getUniqueId() == null) || (other.getUniqueId() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean nameEquals = this.getName().equalsIgnoreCase(other.getName());
|
||||
boolean uuidEquals = this.getUniqueId().equals(other.getUniqueId());
|
||||
boolean idEquals = true;
|
||||
|
||||
if (other instanceof CraftPlayer) {
|
||||
idEquals = this.getEntityId() == ((CraftPlayer) other).getEntityId();
|
||||
}
|
||||
|
||||
return nameEquals && idEquals;
|
||||
return uuidEquals && idEquals;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -947,7 +947,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hash == 0 || hash == 485) {
|
||||
hash = 97 * 5 + (this.getName() != null ? this.getName().toLowerCase().hashCode() : 0);
|
||||
hash = 97 * 5 + (this.getUniqueId() != null ? this.getUniqueId().hashCode() : 0);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user