diff --git a/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch b/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch new file mode 100644 index 000000000..2c7ef11b8 --- /dev/null +++ b/nms-patches/net/minecraft/world/level/entity/PersistentEntitySectionManager.patch @@ -0,0 +1,89 @@ +--- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java ++++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +@@ -82,7 +82,7 @@ + long i = SectionPosition.c(t0.getChunkCoordinates()); + EntitySection entitysection = this.sectionStorage.c(i); + +- entitysection.a((Object) t0); ++ entitysection.a(t0); // CraftBukkit - decompile error + t0.a(new PersistentEntitySectionManager.a(t0, i, entitysection)); + if (!flag) { + this.callbacks.f(t0); +@@ -254,13 +254,13 @@ + } + + private void f() { +- this.chunksToUnload.removeIf((i) -> { ++ this.chunksToUnload.removeIf((java.util.function.LongPredicate) (i) -> { // CraftBukkit - decompile error + return this.chunkVisibility.get(i) != Visibility.HIDDEN ? true : this.d(i); + }); + } + + private void g() { +- ChunkEntities chunkentities; ++ ChunkEntities chunkentities; // CraftBukkit - decompile error + + while ((chunkentities = (ChunkEntities) this.loadingInbox.poll()) != null) { + chunkentities.b().forEach((entityaccess) -> { +@@ -292,7 +292,7 @@ + } + + public void b() { +- this.h().forEach((i) -> { ++ this.h().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error + boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN; + + if (flag) { +@@ -311,7 +311,7 @@ + while (!longset.isEmpty()) { + this.permanentStorage.a(false); + this.g(); +- longset.removeIf((i) -> { ++ longset.removeIf((java.util.function.LongPredicate) (i) -> { // CraftBukkit - decompile error + boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN; + + return flag ? this.d(i) : this.a(i, (entityaccess) -> { +@@ -323,7 +323,15 @@ + } + + public void close() throws IOException { +- this.c(); ++ // CraftBukkit start - add save boolean ++ close(true); ++ } ++ ++ public void close(boolean save) throws IOException { ++ if (save) { ++ this.c(); // PAIL rename saveAll ++ } ++ // CraftBukkit end + this.permanentStorage.close(); + } + +@@ -350,7 +358,7 @@ + public void a(Writer writer) throws IOException { + CSVWriter csvwriter = CSVWriter.a().a("x").a("y").a("z").a("visibility").a("load_status").a("entity_count").a(writer); + +- this.sectionStorage.a().forEach((i) -> { ++ this.sectionStorage.a().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error + PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i); + + this.sectionStorage.a(i).forEach((j) -> { +@@ -389,7 +397,7 @@ + private EntitySection currentSection; + + a(EntityAccess entityaccess, long i, EntitySection entitysection) { +- this.entity = entityaccess; ++ this.entity = (T) entityaccess; // CraftBukkit - decompile error + this.currentSectionKey = i; + this.currentSection = entitysection; + } +@@ -409,7 +417,7 @@ + PersistentEntitySectionManager.this.a(this.currentSectionKey, this.currentSection); + EntitySection entitysection = PersistentEntitySectionManager.this.sectionStorage.c(i); + +- entitysection.a((Object) this.entity); ++ entitysection.a(this.entity); // CraftBukkit - decompile error + this.currentSection = entitysection; + this.currentSectionKey = i; + this.a(visibility, entitysection.c()); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 803873175..208f9b276 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1128,6 +1128,7 @@ public final class CraftServer implements Server { } handle.getChunkProvider().close(save); + handle.entityManager.close(save); // SPIGOT-6722: close entityManager handle.convertable.close(); } catch (Exception ex) { getLogger().log(Level.SEVERE, null, ex);