2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-01-12 07:36:31 +01:00
|
|
|
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
|
2020-08-23 21:57:55 +02:00
|
|
|
index 90c94729edf8d18f33d72e872f7969abef0067a0..2639c17b7f6100533f33124f9e49990cd303d161 100644
|
2020-01-12 07:36:31 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
|
2020-08-23 21:57:55 +02:00
|
|
|
@@ -268,6 +268,12 @@ public interface IEntityAccess {
|
2020-01-12 07:36:31 +01:00
|
|
|
|
|
|
|
@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
|
2020-11-19 16:15:16 +01:00
|
|
|
index c7a39cd7ac8ca48b2b2fb42738406c94150f5d77..a06a9c4a50acdad951da3a95d0c46cf9766164c1 100644
|
2020-01-12 07:36:31 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-11-03 03:22:15 +01:00
|
|
|
@@ -177,6 +177,15 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-01-12 07:36:31 +01:00
|
|
|
}
|
2020-06-26 01:38:24 +02:00
|
|
|
// Paper end
|
2020-01-12 07:36:31 +01:00
|
|
|
|
|
|
|
+ // 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
|
|
|
|
+
|
2020-06-26 01:38:24 +02:00
|
|
|
// Add env and gen to constructor, WorldData -> WorldDataServer
|
2020-08-25 04:22:08 +02:00
|
|
|
public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, 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, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env, executor); // Paper pass executor
|