2018-08-05 22:55:03 +00:00
|
|
|
From ac0033b8223c425d0c0830737002b387d547b36c Mon Sep 17 00:00:00 2001
|
2018-07-31 04:27:45 +00:00
|
|
|
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
|
2018-08-05 22:55:03 +00:00
|
|
|
index 82f4f00a..b0053e5e 100644
|
2018-07-31 04:27:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
|
|
@@ -79,6 +79,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
|
|
private final List<TileEntity> c = Lists.newArrayList();
|
|
|
|
private final Set<TileEntity> tileEntityListUnload = 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 G = 16777215L;
|
2018-08-04 01:20:57 +00:00
|
|
|
@@ -1062,6 +1063,8 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2018-07-31 04:27:45 +00:00
|
|
|
EntityHuman entityhuman = (EntityHuman) entity;
|
|
|
|
|
|
|
|
this.players.add(entityhuman);
|
|
|
|
+ this.playersByName.put(entityhuman.getName(), entityhuman);
|
|
|
|
+ // Paper end
|
|
|
|
this.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2018-08-04 01:20:57 +00:00
|
|
|
@@ -1104,6 +1107,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2018-07-31 04:27:45 +00:00
|
|
|
entity.die();
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.players.remove(entity);
|
|
|
|
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
// Spigot start
|
|
|
|
for ( Object o : worldMaps.d )
|
|
|
|
{
|
2018-08-04 01:20:57 +00:00
|
|
|
@@ -1134,6 +1138,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2018-07-31 04:27:45 +00:00
|
|
|
entity.die();
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.players.remove(entity);
|
|
|
|
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
this.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2018-08-04 01:20:57 +00:00
|
|
|
@@ -2662,6 +2667,8 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2018-07-31 04:27:45 +00:00
|
|
|
|
|
|
|
@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);
|
|
|
|
|
2018-08-04 01:20:57 +00:00
|
|
|
@@ -2671,10 +2678,15 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2018-07-31 04:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-08-04 01:20:57 +00:00
|
|
|
@@ -2684,6 +2696,10 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2018-07-31 04:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
+ */
|
|
|
|
+ Entity entity = ((WorldServer)this).entitiesByUUID.get(uuid);
|
|
|
|
+ return entity instanceof EntityHuman ? (EntityHuman) entity : null;
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void checkSession() throws ExceptionWorldConflict {
|
|
|
|
--
|
2018-08-03 05:29:20 +00:00
|
|
|
2.18.0
|
2018-07-31 04:27:45 +00:00
|
|
|
|