diff --git a/paper-server/src/org/bukkit/craftbukkit/CraftPlayer.java b/paper-server/src/org/bukkit/craftbukkit/CraftPlayer.java index 9e6d44fb67..f10d920c19 100644 --- a/paper-server/src/org/bukkit/craftbukkit/CraftPlayer.java +++ b/paper-server/src/org/bukkit/craftbukkit/CraftPlayer.java @@ -3,10 +3,11 @@ package org.bukkit.craftbukkit; import net.minecraft.server.EntityPlayerMP; import net.minecraft.server.Packet3Chat; +import org.bukkit.Location; import org.bukkit.Player; public class CraftPlayer extends CraftHumanEntity implements Player { - private final EntityPlayerMP entity; + private EntityPlayerMP entity; public CraftPlayer(CraftServer server, EntityPlayerMP entity) { super(server, entity); @@ -22,12 +23,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return entity; } - @Override - public String toString() { - return "CraftPlayer{" + "name=" + getName() + '}'; + public void setHandle(final EntityPlayerMP entity) { + this.entity = entity; } public void sendMessage(String message) { entity.a.b(new Packet3Chat(message)); } + + @Override + public void teleportTo(Location location) { + entity.a.a(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + } + + @Override + public String toString() { + return "CraftPlayer{" + "name=" + getName() + '}'; + } } diff --git a/paper-server/src/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/org/bukkit/craftbukkit/CraftServer.java index 9060d062ad..1fe1ee4473 100644 --- a/paper-server/src/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/org/bukkit/craftbukkit/CraftServer.java @@ -18,7 +18,6 @@ import org.bukkit.plugin.java.JavaPluginLoader; public final class CraftServer implements Server { private final String serverName = "Craftbukkit"; private final String serverVersion; - private final HashMap playerCache = new HashMap(); private final PluginManager pluginManager = new SimplePluginManager(this); protected final MinecraftServer console; @@ -57,28 +56,14 @@ public final class CraftServer implements Server { Player[] players = new Player[online.size()]; for (int i = 0; i < players.length; i++) { - String name = online.get(i).aw; - - if (playerCache.containsKey(name)) { - players[i] = playerCache.get(name); - } else { - players[i] = new CraftPlayer(this, online.get(i)); - playerCache.put(name, players[i]); - } + players[i] = online.get(i).a.getPlayer(); } return players; } - public Player getPlayer(EntityPlayerMP entity) { - Player result = playerCache.get(entity.aw); - - if (result == null) { - result = new CraftPlayer(this, entity); - playerCache.put(entity.aw, result); - } - - return result; + public Player getPlayer(final EntityPlayerMP entity) { + return entity.a.getPlayer(); } public PluginManager getPluginManager() {