mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-03 01:10:37 +01:00
Fixes BUKKIT-3893 - Close world save files when world is
unloaded.
This commit is contained in:
parent
8cea336290
commit
fb51e3066b
@ -1,9 +1,8 @@
|
|||||||
From 9a4bd51255887005eeb7fa78bf013ba9ed166394 Mon Sep 17 00:00:00 2001
|
From d96080a04cb3f9a56af7f4666c8e88d9437b6184 Mon Sep 17 00:00:00 2001
|
||||||
From: md_5 <md_5@live.com.au>
|
From: md_5 <md_5@live.com.au>
|
||||||
Date: Wed, 10 Apr 2013 13:52:52 +1000
|
Date: Wed, 10 Apr 2013 13:52:52 +1000
|
||||||
Subject: [PATCH] mc-dev imports
|
Subject: [PATCH] mc-dev imports
|
||||||
|
|
||||||
2 files changed, 160 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
|
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
@ -177,6 +176,79 @@ index 0000000..53c1cb5
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..900ed68
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||||
|
@@ -0,0 +1,67 @@
|
||||||
|
+package net.minecraft.server;
|
||||||
|
+
|
||||||
|
+import java.io.DataInputStream;
|
||||||
|
+import java.io.DataOutputStream;
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+import java.util.HashMap;
|
||||||
|
+import java.util.Iterator;
|
||||||
|
+import java.util.Map;
|
||||||
|
+
|
||||||
|
+public class RegionFileCache {
|
||||||
|
+
|
||||||
|
+ private static final Map a = new HashMap();
|
||||||
|
+
|
||||||
|
+ public static synchronized RegionFile a(File file1, int i, int j) {
|
||||||
|
+ File file2 = new File(file1, "region");
|
||||||
|
+ File file3 = new File(file2, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
|
||||||
|
+ RegionFile regionfile = (RegionFile) a.get(file3);
|
||||||
|
+
|
||||||
|
+ if (regionfile != null) {
|
||||||
|
+ return regionfile;
|
||||||
|
+ } else {
|
||||||
|
+ if (!file2.exists()) {
|
||||||
|
+ file2.mkdirs();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (a.size() >= 256) {
|
||||||
|
+ a();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ RegionFile regionfile1 = new RegionFile(file3);
|
||||||
|
+
|
||||||
|
+ a.put(file3, regionfile1);
|
||||||
|
+ return regionfile1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static synchronized void a() {
|
||||||
|
+ Iterator iterator = a.values().iterator();
|
||||||
|
+
|
||||||
|
+ while (iterator.hasNext()) {
|
||||||
|
+ RegionFile regionfile = (RegionFile) iterator.next();
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ if (regionfile != null) {
|
||||||
|
+ regionfile.c();
|
||||||
|
+ }
|
||||||
|
+ } catch (IOException ioexception) {
|
||||||
|
+ ioexception.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ a.clear();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static DataInputStream c(File file1, int i, int j) {
|
||||||
|
+ RegionFile regionfile = a(file1, i, j);
|
||||||
|
+
|
||||||
|
+ return regionfile.a(i & 31, j & 31);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static DataOutputStream d(File file1, int i, int j) {
|
||||||
|
+ RegionFile regionfile = a(file1, i, j);
|
||||||
|
+
|
||||||
|
+ return regionfile.b(i & 31, j & 31);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
--
|
--
|
||||||
1.8.2.1
|
1.8.2.1
|
||||||
|
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
From b9d09022528f4e43799bc85e44e915256585d004 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Antony Riley <antony@cyberiantiger.org>
|
||||||
|
Date: Wed, 27 Mar 2013 01:41:54 +0200
|
||||||
|
Subject: [PATCH] Fixes BUKKIT-3893 - Close world save files when world is
|
||||||
|
unloaded.
|
||||||
|
|
||||||
|
|
||||||
|
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 f7ec7bb..f19c600 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -37,6 +37,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;
|
||||||
|
@@ -832,6 +834,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.8.2.1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user