Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
Use UUIDs in CraftPlayer equals and hashCode methods. Fixes BUKKIT-5634
Dieser Commit ist enthalten in:
Ursprung
38fbe60d46
Commit
0a45c3ebf7
@ -222,18 +222,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
OfflinePlayer other = (OfflinePlayer) obj;
|
OfflinePlayer other = (OfflinePlayer) obj;
|
||||||
if ((this.getName() == null) || (other.getName() == null)) {
|
if ((this.getUniqueId() == null) || (other.getUniqueId() == null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean nameEquals = this.getName().equalsIgnoreCase(other.getName());
|
boolean uuidEquals = this.getUniqueId().equals(other.getUniqueId());
|
||||||
boolean idEquals = true;
|
boolean idEquals = true;
|
||||||
|
|
||||||
if (other instanceof CraftPlayer) {
|
if (other instanceof CraftPlayer) {
|
||||||
idEquals = this.getEntityId() == ((CraftPlayer) other).getEntityId();
|
idEquals = this.getEntityId() == ((CraftPlayer) other).getEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nameEquals && idEquals;
|
return uuidEquals && idEquals;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -947,7 +947,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (hash == 0 || hash == 485) {
|
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;
|
return hash;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren