2016-02-29 22:33:06 +01:00
|
|
|
From 5f99873d4186a6be4ce9bbf25c86328c2135edb7 Mon Sep 17 00:00:00 2001
|
2014-07-21 22:46:54 +02:00
|
|
|
From: Antony Riley <antony@cyberiantiger.org>
|
|
|
|
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
|
2015-02-28 12:36:22 +01:00
|
|
|
index b07e7d5..5528019 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- 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 {
|
|
|
|
|
2015-02-28 12:36:22 +01:00
|
|
|
- private static final Map<File, RegionFile> a = Maps.newHashMap();
|
|
|
|
+ public static final Map<File, RegionFile> a = Maps.newHashMap(); // Spigot - private -> public
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
public static synchronized RegionFile a(File file, int i, int j) {
|
|
|
|
File file1 = new File(file, "region");
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 22:33:06 +01:00
|
|
|
index 261b423..f906f60 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 22:33:06 +01:00
|
|
|
@@ -966,6 +966,31 @@ public final class CraftServer implements Server {
|
2014-11-28 02:17:45 +01:00
|
|
|
|
2014-07-21 22:46:54 +02:00
|
|
|
worlds.remove(world.getName().toLowerCase());
|
|
|
|
console.worlds.remove(console.worlds.indexOf(handle));
|
2014-11-28 02:17:45 +01:00
|
|
|
+
|
2014-07-21 22:46:54 +02:00
|
|
|
+ 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2016-02-29 22:33:06 +01:00
|
|
|
2.5.0
|
2014-07-21 22:46:54 +02:00
|
|
|
|