summaryrefslogtreecommitdiffstats
path: root/nms-patches/RegionFileCache.patch
blob: 84697d79f5437a54719a184a365d583f2680d7ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- a/net/minecraft/server/RegionFileCache.java
+++ b/net/minecraft/server/RegionFileCache.java
@@ -74,17 +74,27 @@
         RegionFileCache.a.clear();
     }
 
-    public static DataInputStream d(File file, int i, int j) {
+    // CraftBukkit start - call sites hoisted for synchronization
+    public static synchronized NBTTagCompound d(File file, int i, int j) throws IOException {
         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);
     }
 
-    public static DataOutputStream e(File file, int i, int j) {
+    public static synchronized void e(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
         RegionFile regionfile = a(file, i, j);
 
-        return regionfile.b(i & 31, j & 31);
+        DataOutputStream dataoutputstream = regionfile.b(i & 31, j & 31);
+        NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream);
+        dataoutputstream.close();
     }
+    // CraftBukkit end
 
     public static synchronized boolean chunkExists(File file, int i, int j) {
         RegionFile regionfile = b(file, i, j);