aboutsummaryrefslogtreecommitdiffhomepage
path: root/CraftBukkit-Patches/0024-Close-Unloaded-Save-Files.patch
diff options
context:
space:
mode:
Diffstat (limited to 'CraftBukkit-Patches/0024-Close-Unloaded-Save-Files.patch')
-rw-r--r--CraftBukkit-Patches/0024-Close-Unloaded-Save-Files.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/CraftBukkit-Patches/0024-Close-Unloaded-Save-Files.patch b/CraftBukkit-Patches/0024-Close-Unloaded-Save-Files.patch
new file mode 100644
index 0000000000..6b47d05a03
--- /dev/null
+++ b/CraftBukkit-Patches/0024-Close-Unloaded-Save-Files.patch
@@ -0,0 +1,66 @@
+From e1371e89ed70a4939d4b731fac0b83d6db6f3589 Mon Sep 17 00:00:00 2001
+From: Antony Riley <[email protected]>
+Date: Wed, 27 Mar 2013 01:41:54 +0200
+Subject: [PATCH] Close Unloaded Save Files
+
+
+diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
+index 900ed68..829f4a3 100644
+--- a/src/main/java/net/minecraft/server/RegionFileCache.java
++++ b/src/main/java/net/minecraft/server/RegionFileCache.java
+@@ -10,7 +10,7 @@ import java.util.Map;
+
+ public class RegionFileCache {
+
+- private static final Map a = new HashMap();
++ public static final Map a = new HashMap(); // CraftBukkit - private -> public
+
+ public static synchronized RegionFile a(File file1, int i, int j) {
+ File file2 = new File(file1, "region");
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+index d997b48..6dc4157 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+@@ -85,6 +85,8 @@ import net.minecraft.server.MinecraftServer;
+ import net.minecraft.server.MobEffectList;
+ import net.minecraft.server.PropertyManager;
+ import net.minecraft.server.ServerCommand;
++import net.minecraft.server.RegionFile;
++import net.minecraft.server.RegionFileCache;
+ import net.minecraft.server.ServerNBTManager;
+ import net.minecraft.server.WorldLoaderServer;
+ import net.minecraft.server.WorldManager;
+@@ -1062,6 +1064,30 @@ public final class CraftServer implements Server {
+ worlds.remove(world.getName().toLowerCase());
+ console.worlds.remove(console.worlds.indexOf(handle));
+
++ File parentFolder = world.getWorldFolder().getAbsoluteFile();
++
++ // Synchronized because access to RegionFileCache.a is guarded by this lock.
++ synchronized (RegionFileCache.class) {
++ // RegionFileCache.a should be RegionFileCache.cache
++ Iterator<Map.Entry<File, RegionFile>> i = RegionFileCache.a.entrySet().iterator();
++ while(i.hasNext()) {
++ Map.Entry<File, RegionFile> entry = i.next();
++ File child = entry.getKey().getAbsoluteFile();
++ while (child != null) {
++ if (child.equals(parentFolder)) {
++ i.remove();
++ try {
++ entry.getValue().c(); // Should be RegionFile.close();
++ } catch (IOException ex) {
++ getLogger().log(Level.SEVERE, null, ex);
++ }
++ break;
++ }
++ child = child.getParentFile();
++ }
++ }
++ }
++
+ return true;
+ }
+
+--
+1.9.1
+