2016-06-12 11:28:27 +02:00
|
|
|
--- a/net/minecraft/server/RegionFileCache.java
|
|
|
|
+++ b/net/minecraft/server/RegionFileCache.java
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -36,6 +36,29 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public static synchronized RegionFile b(File file, int i, int j) {
|
|
|
|
+ File file1 = new File(file, "region");
|
|
|
|
+ File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
|
2018-12-13 01:00:00 +01:00
|
|
|
+ RegionFile regionfile = (RegionFile) RegionFileCache.cache.get(file2);
|
2018-08-26 04:00:00 +02:00
|
|
|
+
|
|
|
|
+ if (regionfile != null) {
|
|
|
|
+ return regionfile;
|
|
|
|
+ } else if (file1.exists() && file2.exists()) {
|
2018-12-13 01:00:00 +01:00
|
|
|
+ if (RegionFileCache.cache.size() >= 256) {
|
2018-08-26 04:00:00 +02:00
|
|
|
+ a();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RegionFile regionfile1 = new RegionFile(file2);
|
|
|
|
+
|
2018-12-13 01:00:00 +01:00
|
|
|
+ RegionFileCache.cache.put(file2, regionfile1);
|
2018-08-26 04:00:00 +02:00
|
|
|
+ return regionfile1;
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
public static synchronized void a() {
|
2018-12-13 01:00:00 +01:00
|
|
|
Iterator iterator = RegionFileCache.cache.values().iterator();
|
2018-08-26 04:00:00 +02:00
|
|
|
|
|
|
|
@@ -55,16 +78,32 @@
|
2016-06-12 11:28:27 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
@Nullable
|
2018-07-22 04:00:00 +02:00
|
|
|
- public static DataInputStream read(File file, int i, int j) {
|
2016-06-12 11:28:27 +02:00
|
|
|
+ // CraftBukkit start - call sites hoisted for synchronization
|
2018-07-22 04:00:00 +02:00
|
|
|
+ public static synchronized NBTTagCompound read(File file, int i, int j) throws IOException {
|
2016-06-12 11:28:27 +02:00
|
|
|
RegionFile regionfile = a(file, i, j);
|
|
|
|
|
|
|
|
- return regionfile.a(i & 31, j & 31);
|
|
|
|
+ DataInputStream datainputstream = regionfile.a(i & 31, j & 31);
|
|
|
|
+
|
|
|
|
+ if (datainputstream == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return NBTCompressedStreamTools.a(datainputstream);
|
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
@Nullable
|
2018-07-22 04:00:00 +02:00
|
|
|
- public static DataOutputStream write(File file, int i, int j) {
|
|
|
|
+ public static synchronized void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
|
2016-06-12 11:28:27 +02:00
|
|
|
RegionFile regionfile = a(file, i, j);
|
|
|
|
|
2018-07-22 04:00:00 +02:00
|
|
|
- return regionfile.c(i & 31, j & 31);
|
|
|
|
+ DataOutputStream dataoutputstream = regionfile.c(i & 31, j & 31);
|
2016-06-12 11:28:27 +02:00
|
|
|
+ NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream);
|
|
|
|
+ dataoutputstream.close();
|
2018-08-26 04:00:00 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static synchronized boolean chunkExists(File file, int i, int j) {
|
|
|
|
+ RegionFile regionfile = b(file, i, j);
|
|
|
|
+
|
|
|
|
+ return regionfile != null ? regionfile.d(i & 31, j & 31) : false;
|
2016-06-12 11:28:27 +02:00
|
|
|
}
|
|
|
|
+ // CraftBukkit end
|
2018-08-26 04:00:00 +02:00
|
|
|
}
|