13
0
geforkt von Mirrors/Paper
Paper/nms-patches/RegionFileCache.patch

43 Zeilen
1.9 KiB
Diff

--- a/net/minecraft/server/RegionFileCache.java
+++ b/net/minecraft/server/RegionFileCache.java
2020-08-11 23:00:00 +02:00
@@ -21,7 +21,7 @@
2020-06-25 02:00:00 +02:00
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-08-11 23:00:00 +02:00
@@ -37,6 +37,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-08-11 23:00:00 +02:00
@@ -46,7 +47,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-08-11 23:00:00 +02:00
@@ -81,7 +87,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;