From b331a055090a1c5a25f6f03264b647fe956cf558 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 22 Apr 2020 12:00:50 +1000 Subject: [PATCH] SPIGOT-5680: isChunkGenerated creates empty region files --- nms-patches/RegionFileCache.patch | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch index 05bb3f941b..d756206f5b 100644 --- a/nms-patches/RegionFileCache.patch +++ b/nms-patches/RegionFileCache.patch @@ -17,16 +17,21 @@ RegionFile regionfile1 = new RegionFile(file, this.b); this.cache.putAndMoveToFirst(i, regionfile1); -@@ -43,7 +44,7 @@ +@@ -43,7 +44,12 @@ @Nullable public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException { - RegionFile regionfile = this.getFile(chunkcoordintpair); -+ RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit ++ // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing ++ RegionFile regionfile = this.getFile(chunkcoordintpair, true); ++ if (regionfile == null) { ++ return null; ++ } ++ // CraftBukkit end DataInputStream datainputstream = regionfile.a(chunkcoordintpair); Throwable throwable = null; -@@ -78,7 +79,7 @@ +@@ -78,7 +84,7 @@ } protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { @@ -35,16 +40,3 @@ DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair); Throwable throwable = null; -@@ -114,4 +115,12 @@ - } - - } -+ -+ // CraftBukkit start -+ public boolean chunkExists(ChunkCoordIntPair pos) throws IOException { -+ RegionFile regionfile = getFile(pos, true); -+ -+ return regionfile != null ? regionfile.chunkExists(pos) : false; -+ } -+ // CraftBukkit end - }