Archiviert
13
0

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

Dieser Commit ist enthalten in:
Nathan Adams 2011-12-12 15:34:49 +00:00
Ursprung 82965eb10f
Commit 91ff0b059d
2 geänderte Dateien mit 27 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -4,7 +4,6 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.LinkedHashMap;
import java.util.Map;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.Packet131ItemData;
import net.minecraft.server.Packet200Statistic;
@ -24,6 +23,7 @@ import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.OfflinePlayer;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.configuration.serialization.DelegateDeserialization;
@ -160,14 +160,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (!(obj instanceof OfflinePlayer)) {
return false;
}
final CraftPlayer other = (CraftPlayer) obj;
if ((this.getName() == null) ? (other.getName() != null) : !this.getName().equals(other.getName())) {
OfflinePlayer other = (OfflinePlayer)obj;
if ((this.getName() == null) || (other.getName() == null)) {
return false;
}
return true;
return this.getName().equalsIgnoreCase(other.getName());
}
public void kickPlayer(String message) {