mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 12:11:47 +01:00
1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
44 lines
2.5 KiB
Diff
44 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/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index 04cbcb6a872c0b595a691f705131100341e0ec63..7eec1b181ed99e78cfd43a6f48327133fdfbeee7 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -286,6 +286,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, 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
|
|
diff --git a/src/main/java/net/minecraft/world/level/IEntityAccess.java b/src/main/java/net/minecraft/world/level/IEntityAccess.java
|
|
index 8fdc4b22e8c99d653bd213fe64339c133b46b4e9..1ff9e771788a4ab52129070e355ca48df2949470 100644
|
|
--- a/src/main/java/net/minecraft/world/level/IEntityAccess.java
|
|
+++ b/src/main/java/net/minecraft/world/level/IEntityAccess.java
|
|
@@ -277,6 +277,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);
|
|
|