3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/RegionFileCache.patch

43 Zeilen
1.9 KiB
Diff

--- a/net/minecraft/server/RegionFileCache.java
+++ b/net/minecraft/server/RegionFileCache.java
2020-06-25 02:00:00 +02:00
@@ -20,7 +20,7 @@
this.c = flag;
2018-08-26 04:00:00 +02:00
}
2019-12-10 23:00:00 +01:00
- private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair) throws IOException {
+ private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
2019-04-23 04:00:00 +02:00
long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i);
2018-08-26 04:00:00 +02:00
2020-06-25 02:00:00 +02:00
@@ -36,6 +36,7 @@
2019-04-23 04:00:00 +02:00
}
2019-12-10 23:00:00 +01:00
File file = new File(this.b, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca");
2019-04-23 04:00:00 +02:00
+ if (existingOnly && !file.exists()) return null; // CraftBukkit
2020-06-25 02:00:00 +02:00
RegionFile regionfile1 = new RegionFile(file, this.b, this.c);
2019-04-23 04:00:00 +02:00
this.cache.putAndMoveToFirst(i, regionfile1);
2020-06-25 02:00:00 +02:00
@@ -45,7 +46,12 @@
2018-07-15 02:00:00 +02:00
@Nullable
2019-04-23 04:00:00 +02:00
public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException {
2019-12-10 23:00:00 +01:00
- RegionFile regionfile = this.getFile(chunkcoordintpair);
+ // 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
2019-04-23 04:00:00 +02:00
DataInputStream datainputstream = regionfile.a(chunkcoordintpair);
Throwable throwable = null;
2020-06-25 02:00:00 +02:00
@@ -80,7 +86,7 @@
}
2019-04-23 04:00:00 +02:00
protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
2019-12-10 23:00:00 +01:00
- RegionFile regionfile = this.getFile(chunkcoordintpair);
+ RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit
2019-04-23 04:00:00 +02:00
DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair);
Throwable throwable = null;