Paper/Spigot-Server-Patches/0404-Optimise-IEntityAccess-getPlayerByUUID.patch
Prof-Bloodstone 42433c2626
Updated Upstream (Bukkit/CraftBukkit) (#3980)
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:
09f10fd9 SPIGOT-5950: Add PrepareSmithingEvent event

CraftBukkit Changes:
7c03d257 SPIGOT-6011: End Gateways do not work on Non-Main End Worlds
d492e363 SPIGOT-6015: Small Armor Stand doesn't drop items
5db13eea SPIGOT-5950: Add PrepareSmithingEvent event
2020-07-22 19:35:44 -04:00

45 lines
2.5 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 48e8b005bd9589135eff03a110ecce8776ab208a..74d4c28246e7db850e6d993e07a84b2a6ca24ce2 100644
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
@@ -235,6 +235,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 89dd2695d829024aa3dc48eec5c7dcc114ce3d92..54423fd1133b313d3d2e7550f03e660b9ab6db99 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -172,6 +172,15 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
// Paper end
+ // 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
+
// Add env and gen to constructor, WorldData -> WorldDataServer
public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, ResourceKey<DimensionManager> resourcekey1, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
super(iworlddataserver, resourcekey, resourcekey1, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env, executor); // Paper pass executor