mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 17:07:34 +01:00
43 lines
1.9 KiB
Diff
43 lines
1.9 KiB
Diff
--- a/net/minecraft/server/RegionFileCache.java
|
|
+++ b/net/minecraft/server/RegionFileCache.java
|
|
@@ -20,7 +20,7 @@
|
|
this.c = flag;
|
|
}
|
|
|
|
- private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
|
+ private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
|
|
long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
|
|
RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i);
|
|
|
|
@@ -36,6 +36,7 @@
|
|
}
|
|
|
|
File file = new File(this.b, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
|
+ if (existingOnly && !file.exists()) return null; // CraftBukkit
|
|
RegionFile regionfile1 = new RegionFile(file, this.b, this.c);
|
|
|
|
this.cache.putAndMoveToFirst(i, regionfile1);
|
|
@@ -45,7 +46,12 @@
|
|
|
|
@Nullable
|
|
public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
|
- 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
|
|
DataInputStream datainputstream = regionfile.a(chunkcoordintpair);
|
|
Throwable throwable = null;
|
|
|
|
@@ -80,7 +86,7 @@
|
|
}
|
|
|
|
protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
|
|
- RegionFile regionfile = this.getFile(chunkcoordintpair);
|
|
+ RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit
|
|
DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair);
|
|
Throwable throwable = null;
|
|
|