Paper/Spigot-Server-Patches/0419-Optimise-IEntityAccess-getPlayerByUUID.patch
Aikar 36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00

45 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 11 Jan 2020 21:50:56 -0800
Subject: [PATCH] Optimise IEntityAccess#getPlayerByUUID
Use the world entity map instead of iterating over all players
diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
index d5c284cdd10d33f5f1b7f456d6a384a44eafb139..4157e50e4d99c029759bffcb48a8d645487554c8 100644
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
@@ -219,6 +219,12 @@ public interface IEntityAccess {
@Nullable
default EntityHuman b(UUID uuid) {
+ // Paper start - allow WorldServer to override
+ return this.getPlayerByUUID(uuid);
+ }
+ @Nullable
+ default EntityHuman getPlayerByUUID(UUID uuid) {
+ // Paper end
for (int i = 0; i < this.getPlayers().size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.getPlayers().get(i);
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 17560a20fce7f42f98aacc42b9d4c3ab992af3cf..c348e3e5008e9213f96f2eb718cfb07c340bf77b 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -82,6 +82,15 @@ public class WorldServer extends World {
return new Throwable(entity + " Added to world at " + new java.util.Date());
}
+ // Paper start - optimise getPlayerByUUID
+ @Nullable
+ @Override
+ public EntityHuman getPlayerByUUID(UUID uuid) {
+ Entity player = this.entitiesByUUID.get(uuid);
+ return (player instanceof EntityHuman) ? (EntityHuman)player : null;
+ }
+ // Paper end
+
// Paper start - Asynchronous IO
public final com.destroystokyo.paper.io.PaperFileIOThread.ChunkDataController poiDataController = new com.destroystokyo.paper.io.PaperFileIOThread.ChunkDataController() {
@Override