mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Rebuild patches
This commit is contained in:
parent
68e3c1e364
commit
3388d414cf
15 changed files with 40 additions and 188 deletions
|
@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient {
|
||||
public void broadcast(net.md_5.bungee.api.chat.BaseComponent... components) {
|
||||
public void restart() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
+
|
||||
|
|
|
@ -37,4 +37,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
|
||||
Spigot spigot();
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -140,4 +140,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -127,4 +127,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -33,4 +33,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
public Chunk getChunkAt(int x, int z) {
|
||||
return this.world.chunkProviderServer.getChunkAt(x, z).bukkitChunk;
|
||||
}
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -63,4 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ Bukkit.getLogger().info( "Data value allowed items: " + StringUtils.join(dataValueAllowedItems, ", ") );
|
||||
+ }
|
||||
}
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -22,4 +22,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
|
||||
public void setCarried(IBlockData iblockdata) {
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -16,4 +16,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
<archive>
|
||||
<manifestEntries>
|
||||
<Main-Class>org.bukkit.craftbukkit.Main</Main-Class>
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -24,4 +24,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
Vec3D vec3d = new Vec3D(this.posX, this.posY, this.posZ);
|
||||
|
||||
for (int l1 = 0; l1 < list.size(); ++l1) {
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -23,4 +23,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
|
||||
@Override
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -197,4 +197,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
};
|
||||
|
||||
public Player.Spigot spigot()
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -1,174 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 8 Mar 2015 04:03:56 -0500
|
||||
Subject: [PATCH] Player lookup improvements
|
||||
|
||||
Minecraft and CraftBukkit both use Arrays to store online players,
|
||||
and any time a player needs to be looked up by name or UUID,
|
||||
the system iterates all online players and does a name or UUID comparison.
|
||||
|
||||
This is very ineffecient and can reduce performance on servers with high player count.
|
||||
|
||||
By using a map based approach for player lookups, player lookup should
|
||||
be consistent in performance regardless of how many players are online.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- 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 g = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
private final MinecraftServer server;
|
||||
public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
|
||||
+ // PaperSpigot start - Player lookup improvements
|
||||
+ public final Map<String, EntityPlayer> playerMap = new java.util.HashMap<String, EntityPlayer>() {
|
||||
+ @Override
|
||||
+ public EntityPlayer put(String key, EntityPlayer value) {
|
||||
+ return super.put(key.toLowerCase(), value);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public EntityPlayer get(Object key) {
|
||||
+ // put the .playerConnection check done in other places here
|
||||
+ EntityPlayer player = super.get(key instanceof String ? ((String) key).toLowerCase() : key);
|
||||
+ return (player != null && player.playerConnection != null) ? player : null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean containsKey(Object key) {
|
||||
+ return get(key) != null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public EntityPlayer remove(Object key) {
|
||||
+ return super.remove(key instanceof String ? ((String) key).toLowerCase() : key);
|
||||
+ }
|
||||
+ };
|
||||
+ // PaperSpigot end
|
||||
private final Map<UUID, EntityPlayer> j = Maps.newHashMap();
|
||||
private final GameProfileBanList k;
|
||||
private final IpBanList l;
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
|
||||
public void onPlayerJoin(EntityPlayer entityplayer, String joinMessage) { // CraftBukkit added param
|
||||
this.players.add(entityplayer);
|
||||
+ this.playerMap.put(entityplayer.getName(), entityplayer); // PaperSpigot
|
||||
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
|
||||
UUID uuid = entityplayer.getUniqueID();
|
||||
EntityPlayer entityplayer1 = (EntityPlayer) this.j.get(uuid);
|
||||
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
|
||||
EntityPlayer entityplayer;
|
||||
|
||||
+ // PaperSpigot start - Use exact lookup below
|
||||
+ /*
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
entityplayer = (EntityPlayer) this.players.get(i);
|
||||
if (entityplayer.getUniqueID().equals(uuid)) {
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
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");
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer(String s) {
|
||||
+ if (true) { return playerMap.get(s); } // PaperSpigot
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
EntityPlayer entityplayer;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
||||
@@ -0,0 +0,0 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
- for (Object obj : server.getHandle().players) {
|
||||
- EntityPlayer player = (EntityPlayer) obj;
|
||||
- if (player.getUniqueID().equals(getUniqueId())) {
|
||||
- return (player.playerConnection != null) ? player.playerConnection.getPlayer() : null;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return null;
|
||||
+ // PaperSpigot - Improved player lookup, replace entire method
|
||||
+ final EntityPlayer playerEntity = server.getHandle().a(getUniqueId());
|
||||
+ return playerEntity != null ? playerEntity.getBukkitEntity() : null;
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
public Player getPlayer(final String name) {
|
||||
Validate.notNull(name, "Name cannot be null");
|
||||
|
||||
- Player found = null;
|
||||
+ // PaperSpigot start - Improved player lookup changes
|
||||
+ Player found = getPlayerExact(name);
|
||||
+ if (found != null) {
|
||||
+ return found;
|
||||
+ }
|
||||
+ // PaperSpigot end
|
||||
String lowerName = name.toLowerCase();
|
||||
int delta = Integer.MAX_VALUE;
|
||||
for (Player player : getOnlinePlayers()) {
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
public Player getPlayerExact(String name) {
|
||||
Validate.notNull(name, "Name cannot be null");
|
||||
|
||||
- String lname = name.toLowerCase();
|
||||
-
|
||||
- for (Player player : getOnlinePlayers()) {
|
||||
- if (player.getName().equalsIgnoreCase(lname)) {
|
||||
- return player;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return null;
|
||||
+ // PaperSpigot start - Improved player lookup, replace whole method
|
||||
+ EntityPlayer player = playerList.playerMap.get(name);
|
||||
+ return player != null ? player.getBukkitEntity() : null;
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
- for (Object obj : server.getHandle().players) {
|
||||
- EntityPlayer player = (EntityPlayer) obj;
|
||||
- if (player.getName().equalsIgnoreCase(getName())) {
|
||||
- return true;
|
||||
- }
|
||||
- }
|
||||
- return false;
|
||||
+ return server.getHandle().a(getUniqueId()) != null; // PaperSpigot - replace whole method
|
||||
}
|
||||
|
||||
public InetSocketAddress getAddress() {
|
||||
--
|
|
@ -63,4 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
// Spigot start
|
||||
finally {
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -18,4 +18,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
|
||||
public CrashReport b(CrashReport crashreport) {
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
|
@ -169,4 +169,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ }
|
||||
}
|
||||
--
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
||||
|
|
Loading…
Reference in a new issue