PaperMC/Spigot-Server-Patches/0313-World-EntityHuman-Lookup-Optimizations.patch
Shane Freeder ea855e2b46 Updated Upstream (Bukkit/CraftBukkit/Spigot)
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

Developers!: You will need to clean up your work/Minecraft/1.13.2 folder
for this

Also, restore a patch that was dropped in the last upstream

Bukkit Changes:
279eeab3 Fix command description not being set
96e2bb18 Remove debug print from SyntheticEventTest

CraftBukkit Changes:
d3ed1516 Fix dangerously threaded beacons
217a293d Don't relocate joptsimple to allow --help to work.
1be05a21 Prepare for imminent Java 12 release
a49270b2 Mappings Update
5259d80c SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports

Spigot Changes:
e6eb36f2 Rebuild patches
2019-03-20 01:55:16 +00:00

82 lines
3.5 KiB
Diff

From 20c9c4952328ef753d46754008f17efcc036d085 Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Mon, 30 Jul 2018 02:42:49 -0400
Subject: [PATCH] World EntityHuman Lookup Optimizations
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 814950bde..748ab8212 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -76,6 +76,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
private final List<TileEntity> c = Lists.newArrayList();
private final Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper
public final List<EntityHuman> players = Lists.newArrayList();
+ public final Map<String, EntityHuman> playersByName = Maps.newHashMap(); // Paper - World EntityHuman Lookup Optimizations
public final List<Entity> k = Lists.newArrayList();
protected final IntHashMap<Entity> entitiesById = new IntHashMap<>();
private final long F = 16777215L;
@@ -1030,6 +1031,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
+ this.playersByName.put(entityhuman.getName(), entityhuman);
+ // Paper end
this.everyoneSleeping();
}
@@ -1072,6 +1075,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
// Spigot start
for ( WorldPersistentData worldData : worldMaps.worldMap.values() )
{
@@ -1105,6 +1109,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
this.everyoneSleeping();
}
@@ -2675,6 +2680,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@Nullable
public EntityHuman a(String s) {
+ // Paper start - World EntityHuman Lookup Optimizations
+ /*
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -2684,10 +2691,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
return null;
+ */
+ return this.playersByName.get(s);
+ // Paper end
}
@Nullable
public EntityHuman b(UUID uuid) {
+ // Paper start - World EntityHuman Lookup Optimizations
+ /*
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -2697,6 +2709,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
return null;
+ */
+ Entity entity = ((WorldServer)this).entitiesByUUID.get(uuid);
+ return entity instanceof EntityHuman ? (EntityHuman) entity : null;
+ // Paper end
}
public void checkSession() throws ExceptionWorldConflict {
--
2.21.0