Update PaperSpigot to Minecraft 1.8.3

This commit is contained in:
Zach Brown
2015-03-07 19:16:09 -06:00
parent 64cd5dcd0c
commit 6538ccd924
44 changed files with 813 additions and 726 deletions

View File

@@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 28 Nov 2014 13:43:11 -0600
Date: Sun, 8 Mar 2015 04:03:56 -0500
Subject: [PATCH] Player lookup improvements
Minecraft and CraftBukkit both use Arrays to store online players,
@@ -17,9 +17,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -0,0 +0,0 @@ public abstract class PlayerList {
private static final SimpleDateFormat i = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
private final MinecraftServer server;
public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety, public
+ // PaperSpigot start - Player lookup improvements
+ public final Map<String, EntityPlayer> playerMap = new java.util.HashMap<String, EntityPlayer>() {
+ @Override
@@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ };
+ // PaperSpigot end
public final Map f = Maps.newHashMap();
private final Map<UUID, EntityPlayer> j = Maps.newHashMap();
private final GameProfileBanList k;
private final IpBanList l;
@@ -0,0 +0,0 @@ public abstract class PlayerList {
@@ -53,22 +53,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void onPlayerJoin(EntityPlayer entityplayer, String joinMessage) { // CraftBukkit added param
this.players.add(entityplayer);
+ this.playerMap.put(entityplayer.getName(), entityplayer); // PaperSpigot
this.f.put(entityplayer.getUniqueID(), entityplayer);
// this.sendAll(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below
this.j.put(entityplayer.getUniqueID(), entityplayer);
// this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
@@ -0,0 +0,0 @@ public abstract class PlayerList {
worldserver.kill(entityplayer);
worldserver.getPlayerChunkMap().removePlayer(entityplayer);
this.players.remove(entityplayer);
+ this.playerMap.remove(entityplayer.getName()); // PaperSpigot
this.f.remove(entityplayer.getUniqueID());
this.o.remove(entityplayer.getUniqueID());
// CraftBukkit start
UUID uuid = entityplayer.getUniqueID();
EntityPlayer entityplayer1 = (EntityPlayer) this.j.get(uuid);
@@ -0,0 +0,0 @@ public abstract class PlayerList {
EntityPlayer entityplayer;
+ // PaperSpigot - Use exact lookup below
+ // PaperSpigot start - Use exact lookup below
+ /*
for (int i = 0; i < this.players.size(); ++i) {
entityplayer = (EntityPlayer) this.players.get(i);
@@ -79,6 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityplayer = (EntityPlayer) iterator.next();
+ */
+ if ((entityplayer = this.a(uuid)) != null) {
+ // PaperSpigot end
savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
entityplayer.playerConnection.disconnect("You logged in from another location");
}
@@ -147,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // PaperSpigot start - Improved player lookup, replace whole method
+ EntityPlayer player = playerList.playerMap.get(name);
+ return player != null ? player.getBukkitEntity() : null;
+ // PaperSpigot end
+ // PaperSpigot end
}
@Override
@@ -170,6 +171,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
public InetSocketAddress getAddress() {
--
1.9.5.msysgit.0
--