From 0a45c3ebf79b8077d7ae324ba186639ed66f8446 Mon Sep 17 00:00:00 2001 From: Daniel Naylor Date: Mon, 26 May 2014 20:33:10 +0100 Subject: [PATCH] Use UUIDs in CraftPlayer equals and hashCode methods. Fixes BUKKIT-5634 --- .../java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 55ea121b54..a0e27bc327 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -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; }