mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
Fixed player handle being reset on death or disconnection
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
19dcaeeb01
commit
2250c18a63
2 changed files with 17 additions and 22 deletions
|
@ -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() + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, Player> playerCache = new HashMap<String, Player>();
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue