Remove chunks after calling ChunkUnloadEvent (Fixes #2919)

This commit is contained in:
Shane Freeder 2020-01-30 16:57:46 +00:00
parent 4e48785d91
commit b21010e7e3
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C

View file

@ -1,4 +1,4 @@
From cd1f391366035ee68c3eb7e2a1aa5ba19c2d7da2 Mon Sep 17 00:00:00 2001 From 9360a474d1de17fd98648746c9ec18708a1711ad Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 20:55:47 -0400 Date: Mon, 28 Mar 2016 20:55:47 -0400
Subject: [PATCH] MC Utils Subject: [PATCH] MC Utils
@ -1700,7 +1700,7 @@ index c88a62f6b..5dbd3e60f 100644
this.d = i; this.d = i;
} }
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 55373cae0..a263f60d4 100644 index 55373cae0..517014d21 100644
--- a/src/main/java/net/minecraft/server/Chunk.java --- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -25,7 +25,7 @@ import org.apache.logging.log4j.Logger; @@ -25,7 +25,7 @@ import org.apache.logging.log4j.Logger;
@ -1785,14 +1785,14 @@ index 55373cae0..a263f60d4 100644
if (server != null) { if (server != null) {
/* /*
* If it's a new world, the first few chunks are generated inside * If it's a new world, the first few chunks are generated inside
@@ -540,6 +560,7 @@ public class Chunk implements IChunkAccess { @@ -545,6 +565,7 @@ public class Chunk implements IChunkAccess {
}
public void unloadCallback() {
+ ((WorldServer)this.world).getChunkProvider().removeLoadedChunk(this); // Paper
org.bukkit.Server server = this.world.getServer();
org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isNeedsSaving());
server.getPluginManager().callEvent(unloadEvent); server.getPluginManager().callEvent(unloadEvent);
// note: saving can be prevented, but not forced if no saving is actually required
this.mustNotSave = !unloadEvent.isSaveChunk();
+ ((WorldServer)this.world).getChunkProvider().removeLoadedChunk(this); // Paper
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java
index 11c4d23ba..53c15c1c0 100644 index 11c4d23ba..53c15c1c0 100644
--- a/src/main/java/net/minecraft/server/ChunkCache.java --- a/src/main/java/net/minecraft/server/ChunkCache.java
@ -3281,5 +3281,5 @@ index 1aec70a1f..f72c13bed 100644
private int initialCapacity; private int initialCapacity;
-- --
2.25.0.windows.1 2.25.0