Don't unregister the primary dimensions on world unload

This commit is contained in:
Aikar 2020-05-27 00:15:57 -04:00
parent 21f9efa2ca
commit b88ee11f5a
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
2 changed files with 9 additions and 6 deletions

View File

@ -225,7 +225,7 @@ index b701db638370c0d07d5be0f61c6cbf19168cde8e..4ea3468614df36e1c148a44bb15d2201
} }
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 75906f794205f5b7fe894163e1b13bfd85c2b419..485e5d2778064c64c8dc8375b18c785649049184 100644 index 8cd77117cdb81e3fbd196415f8ac82d3aeddcb12..00ad80bb74bd581e3fa1bf82356ee5b7bc656bfe 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -485,6 +485,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -485,6 +485,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -304,7 +304,7 @@ index b627180729a24a83ca383f83aee53133ea1b398e..f49193d9d7cd9655fdedf64bebdcf4e1
@Override @Override
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 093dbeae2784d51dae74f66e3e1ce5bf6a370428..c47988c676ae2981e20980b47d58cd81ca68bb9c 100644 index 093dbeae2784d51dae74f66e3e1ce5bf6a370428..99e1e902d8fdf33c157416c5d6abc71b495ac48e 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java --- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -150,6 +150,37 @@ public class Main { @@ -150,6 +150,37 @@ public class Main {
@ -345,7 +345,7 @@ index 093dbeae2784d51dae74f66e3e1ce5bf6a370428..c47988c676ae2981e20980b47d58cd81
try { try {
options = parser.parse(args); options = parser.parse(args);
} catch (joptsimple.OptionException ex) { } catch (joptsimple.OptionException ex) {
@@ -245,8 +276,59 @@ public class Main { @@ -245,8 +276,61 @@ public class Main {
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
@ -356,6 +356,7 @@ index 093dbeae2784d51dae74f66e3e1ce5bf6a370428..c47988c676ae2981e20980b47d58cd81
+ tryPreloadClass("com.google.common.collect.Iterators$PeekingImpl"); + tryPreloadClass("com.google.common.collect.Iterators$PeekingImpl");
+ tryPreloadClass("com.google.common.collect.MapMakerInternalMap$Values"); + tryPreloadClass("com.google.common.collect.MapMakerInternalMap$Values");
+ tryPreloadClass("com.google.common.collect.MapMakerInternalMap$ValueIterator"); + tryPreloadClass("com.google.common.collect.MapMakerInternalMap$ValueIterator");
+ tryPreloadClass("com.google.common.collect.MapMakerInternalMap$WriteThroughEntry");
+ tryPreloadClass("com.google.common.collect.Iterables"); + tryPreloadClass("com.google.common.collect.Iterables");
+ for (int i = 1; i <= 15; i++) { + for (int i = 1; i <= 15; i++) {
+ tryPreloadClass("com.google.common.collect.Iterables$" + i, false); + tryPreloadClass("com.google.common.collect.Iterables$" + i, false);
@ -383,6 +384,7 @@ index 093dbeae2784d51dae74f66e3e1ce5bf6a370428..c47988c676ae2981e20980b47d58cd81
+ tryPreloadClass("org.slf4j.helpers.FormattingTuple"); + tryPreloadClass("org.slf4j.helpers.FormattingTuple");
+ tryPreloadClass("org.slf4j.helpers.BasicMarker"); + tryPreloadClass("org.slf4j.helpers.BasicMarker");
+ tryPreloadClass("org.slf4j.helpers.Util"); + tryPreloadClass("org.slf4j.helpers.Util");
+ tryPreloadClass("com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent");
+ // Minecraft, seen during saving + // Minecraft, seen during saving
+ tryPreloadClass("net.minecraft.server.LightEngineLayerEventListener$Void"); + tryPreloadClass("net.minecraft.server.LightEngineLayerEventListener$Void");
+ tryPreloadClass("net.minecraft.server.LightEngineLayerEventListener"); + tryPreloadClass("net.minecraft.server.LightEngineLayerEventListener");

View File

@ -6,16 +6,17 @@ Subject: [PATCH] Fix CraftServer.unloadWorld Leak
The dimension manager was still registered which leaked the entire World The dimension manager was still registered which leaked the entire World
diff --git a/src/main/java/net/minecraft/server/DimensionManager.java b/src/main/java/net/minecraft/server/DimensionManager.java diff --git a/src/main/java/net/minecraft/server/DimensionManager.java b/src/main/java/net/minecraft/server/DimensionManager.java
index 5724fe6e57d3671b4978aecaf217ac4c2e0d7f82..3af9709a8717b1d9c445c3b04163027177a81711 100644 index 393bc4dc700bbf8653db0662c7957f676b0a647a..410ab224fbb05bfbf4aa847d69b150bfe75d32f6 100644
--- a/src/main/java/net/minecraft/server/DimensionManager.java --- a/src/main/java/net/minecraft/server/DimensionManager.java
+++ b/src/main/java/net/minecraft/server/DimensionManager.java +++ b/src/main/java/net/minecraft/server/DimensionManager.java
@@ -20,6 +20,14 @@ public class DimensionManager implements MinecraftSerializable { @@ -20,6 +20,15 @@ public class DimensionManager implements MinecraftSerializable {
private final boolean hasSkyLight; private final boolean hasSkyLight;
private final GenLayerZoomer genLayerZoomer; private final GenLayerZoomer genLayerZoomer;
+ // Paper start + // Paper start
+ public static void unregister(String s, DimensionManager dimensionmanager) { + public static void unregister(String s, DimensionManager dimensionmanager) {
+ MinecraftServer.getServer().execute(() -> { + if (dimensionmanager == OVERWORLD || dimensionmanager == NETHER || dimensionmanager == THE_END) { return; } // do not unregister the default worlds
+ MCUtil.MAIN_EXECUTOR.execute(() -> {
+ RegistryMaterials<DimensionManager> registry = (RegistryMaterials<DimensionManager>) IRegistry.DIMENSION_TYPE; + RegistryMaterials<DimensionManager> registry = (RegistryMaterials<DimensionManager>) IRegistry.DIMENSION_TYPE;
+ registry.deleteValue(new MinecraftKey(s), dimensionmanager); + registry.deleteValue(new MinecraftKey(s), dimensionmanager);
+ }); + });