diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 3e67ddecbb..a6d9c37749 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1,28 +1,23 @@ package org.bukkit.craftbukkit.entity; -import com.google.common.collect.MapMaker; +import java.util.List; +import java.util.UUID; + import net.minecraft.server.*; -import org.bukkit.Location; import org.bukkit.EntityEffect; +import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.entity.Vehicle; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import org.bukkit.util.Vector; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - public abstract class CraftEntity implements org.bukkit.entity.Entity { - private static final Map players = new MapMaker().softValues().makeMap(); protected final CraftServer server; protected Entity entity; private EntityDamageEvent lastDamageEvent; @@ -39,7 +34,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityLiving) { // Players if (entity instanceof EntityHuman) { - if (entity instanceof EntityPlayer) { return getPlayer((EntityPlayer) entity); } + if (entity instanceof EntityPlayer) { return new CraftPlayer(server, (EntityPlayer) entity); } else { return new CraftHumanEntity(server, (EntityHuman) entity); } } else if (entity instanceof EntityCreature) { @@ -275,19 +270,6 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return getHandle().uniqueId; } - private static CraftPlayer getPlayer(EntityPlayer entity) { - CraftPlayer result = players.get(entity.name); - - if (result == null) { - result = new CraftPlayer((CraftServer) Bukkit.getServer(), entity); - players.put(entity.name, result); - } else { - result.setHandle(entity); - } - - return result; - } - public int getTicksLived() { return getHandle().ticksLived; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 208e162274..613963fc67 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.collect.ImmutableSet; import com.google.common.collect.MapMaker; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.InetSocketAddress; @@ -13,30 +14,17 @@ import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; + import net.minecraft.server.*; import org.apache.commons.lang.Validate; -import org.bukkit.*; - -import net.minecraft.server.Container; -import net.minecraft.server.EntityPlayer; -import net.minecraft.server.Packet131ItemData; -import net.minecraft.server.Packet200Statistic; -import net.minecraft.server.Packet201PlayerInfo; -import net.minecraft.server.Packet3Chat; -import net.minecraft.server.Packet51MapChunk; -import net.minecraft.server.Packet53BlockChange; -import net.minecraft.server.Packet54PlayNoteBlock; -import net.minecraft.server.Packet61WorldEvent; -import net.minecraft.server.Packet6SpawnPosition; -import net.minecraft.server.Packet70Bed; -import net.minecraft.server.WorldServer; import org.apache.commons.lang.NotImplementedException; + +import org.bukkit.*; import org.bukkit.Achievement; import org.bukkit.Material; import org.bukkit.Statistic; import org.bukkit.World; -import org.bukkit.block.BlockFace; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.conversations.Conversation; import org.bukkit.conversations.ConversationAbandonedEvent; @@ -57,7 +45,6 @@ import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.StandardMessenger; -import org.bukkit.potion.Potion; @DelegateDeserialization(CraftOfflinePlayer.class) public class CraftPlayer extends CraftHumanEntity implements Player { @@ -211,7 +198,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if ((this.getName() == null) || (other.getName() == null)) { return false; } - return this.getName().equalsIgnoreCase(other.getName()); + + boolean nameEquals = this.getName().equalsIgnoreCase(other.getName()); + boolean idEquals = true; + + if (other instanceof CraftPlayer) { + idEquals = this.getEntityId() == ((CraftPlayer) other).getEntityId(); + } + + return nameEquals && idEquals; } public void kickPlayer(String message) { @@ -827,6 +822,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void disconnect(String reason) { conversationTracker.abandonAllConversations(); + perm.clearPermissions(); } public boolean isFlying() {