Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
83 Zeilen
3.5 KiB
Diff
83 Zeilen
3.5 KiB
Diff
From 7ac07ac07ac07ac07ac07ac07ac07ac07ac07ac0 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 7ac07ac07ac0..7ac07ac07ac0 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -81,6 +81,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;
|
|
@@ -1096,6 +1097,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();
|
|
}
|
|
|
|
@@ -1138,6 +1141,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.a.values() )
|
|
{
|
|
@@ -1171,6 +1175,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();
|
|
}
|
|
|
|
@@ -2741,6 +2746,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);
|
|
|
|
@@ -2750,10 +2757,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);
|
|
|
|
@@ -2763,6 +2775,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.19.1
|
|
|