spigot/CraftBukkit-Patches/0089-Plug-WorldMap-Memory-Leak.patch
2019-04-24 10:30:28 +10:00

44 lines
1.7 KiB
Diff

From 2e97d01581bfc84d5848d0fca3b933f99beafe21 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 8 Aug 2014 19:57:03 +1000
Subject: [PATCH] Plug WorldMap Memory Leak
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 89b6d318..556e467a 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1022,6 +1022,30 @@ public class WorldServer extends World {
}
public void unregisterEntity(Entity entity) {
+ // Spigot start
+ if ( entity instanceof EntityHuman )
+ {
+ this.getMinecraftServer().worldServer.values().stream().map( WorldServer::getWorldPersistentData ).forEach( (worldData) ->
+ {
+ for (Object o : worldData.data.values() )
+ {
+ if ( o instanceof WorldMap )
+ {
+ WorldMap map = (WorldMap) o;
+ map.humans.remove( (EntityHuman) entity );
+ for ( Iterator<WorldMap.WorldMapHumanTracker> iter = (Iterator<WorldMap.WorldMapHumanTracker>) map.i.iterator(); iter.hasNext(); )
+ {
+ if ( iter.next().trackee == entity )
+ {
+ iter.remove();
+ }
+ }
+ }
+ }
+ } );
+ }
+ // Spigot end
+
if (entity instanceof EntityEnderDragon) {
EntityComplexPart[] aentitycomplexpart = ((EntityEnderDragon) entity).dT();
int i = aentitycomplexpart.length;
--
2.20.1