2013-03-23 00:08:09 +01:00
|
|
|
From 6de20346387435347c9a64a000c53f085db2a291 Mon Sep 17 00:00:00 2001
|
2013-03-07 10:12:53 +01:00
|
|
|
From: md_5 <md_5@live.com.au>
|
|
|
|
Date: Thu, 7 Mar 2013 20:12:46 +1100
|
|
|
|
Subject: [PATCH] Thread safety. Adds thread safety for chunk load / unload
|
|
|
|
methods.
|
|
|
|
|
|
|
|
---
|
|
|
|
src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 3 +++
|
|
|
|
1 file changed, 3 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2013-03-22 23:48:22 +01:00
|
|
|
index 80762c1..3bfc669 100644
|
2013-03-07 10:12:53 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2013-03-16 23:14:16 +01:00
|
|
|
@@ -256,6 +256,7 @@ public class CraftWorld implements World {
|
2013-03-07 10:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean unloadChunkRequest(int x, int z, boolean safe) {
|
|
|
|
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous chunk unload!");
|
|
|
|
if (safe && isChunkInUse(x, z)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-03-16 23:14:16 +01:00
|
|
|
@@ -266,6 +267,7 @@ public class CraftWorld implements World {
|
2013-03-07 10:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean unloadChunk(int x, int z, boolean save, boolean safe) {
|
|
|
|
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous chunk unload!");
|
|
|
|
if (safe && isChunkInUse(x, z)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-03-16 23:14:16 +01:00
|
|
|
@@ -333,6 +335,7 @@ public class CraftWorld implements World {
|
2013-03-07 10:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean loadChunk(int x, int z, boolean generate) {
|
|
|
|
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous chunk load!");
|
|
|
|
chunkLoadCount++;
|
|
|
|
if (generate) {
|
|
|
|
// Use the default variant of loadChunk when generate == true.
|
|
|
|
--
|
2013-03-22 23:48:22 +01:00
|
|
|
1.8.1-rc2
|
2013-03-07 10:12:53 +01:00
|
|
|
|