aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0073-Don-t-create-Region-File-s-when-checking-if-chunk-ex.patch
blob: 6cd9524cd05c066a378f9164fd5eac139911ecef (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From 4110f43983a26695d465396b2a0d5af28b47f9c7 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 3 Nov 2015 21:05:41 -0500
Subject: [PATCH] Don't create Region File's when checking if chunk exists

Plugins like Dynap can end up creating tons of emtpy Region Files
when using chunkExists.

diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 206e3aa..6b24490 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -36,7 +36,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
             }
         }
 
-        return RegionFileCache.a(this.d, i, j).chunkExists(i & 31, j & 31);
+        final RegionFile region = RegionFileCache.a(this.d, i, j, false); // PaperSpigot
+        return region != null && region.chunkExists(i & 31, j & 31); // PaperSpigot
     }
     // CraftBukkit end
 
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index 5528019..5b000c4 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -12,7 +12,12 @@ public class RegionFileCache {
 
     public static final Map<File, RegionFile> a = Maps.newHashMap(); // Spigot - private -> public
 
+    // PaperSpigot start
     public static synchronized RegionFile a(File file, int i, int j) {
+        return a(file, i, j, true);
+    }
+    public static synchronized RegionFile a(File file, int i, int j, boolean create) {
+        // PaperSpigot end
         File file1 = new File(file, "region");
         File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
         RegionFile regionfile = (RegionFile) RegionFileCache.a.get(file2);
@@ -20,6 +25,7 @@ public class RegionFileCache {
         if (regionfile != null) {
             return regionfile;
         } else {
+            if (!create && !file2.exists()) { return null; } // PaperSpigot
             if (!file1.exists()) {
                 file1.mkdirs();
             }
-- 
2.6.3