2013-03-23 08:05:22 +01:00
|
|
|
From 67cddbc9856c267a110cf7531b8fde518e327613 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
|
2013-03-23 08:05:22 +01:00
|
|
|
Subject: [PATCH] Async Operation Catching
|
2013-03-07 10:12:53 +01:00
|
|
|
|
2013-03-23 08:05:22 +01:00
|
|
|
Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread.
|
2013-03-07 10:12:53 +01:00
|
|
|
---
|
2013-03-23 08:05:22 +01:00
|
|
|
src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 3 +++
|
|
|
|
src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 1 +
|
|
|
|
2 files changed, 4 insertions(+)
|
2013-03-07 10:12:53 +01:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2013-03-23 07:56:28 +01:00
|
|
|
index 9343d46..b569dc4 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-23 07:56:28 +01:00
|
|
|
@@ -232,6 +232,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-23 07:56:28 +01:00
|
|
|
@@ -242,6 +243,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-23 07:56:28 +01:00
|
|
|
@@ -309,6 +311,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-23 08:05:22 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
index 70111e7..59e63ef 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
@@ -213,6 +213,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void kickPlayer(String message) {
|
|
|
|
+ if (Thread.currentThread() != MinecraftServer.getServer().primaryThread) throw new IllegalStateException("Asynchronous player kick!");
|
|
|
|
if (getHandle().playerConnection == null) return;
|
|
|
|
|
|
|
|
getHandle().playerConnection.disconnect(message == null ? "" : message);
|
2013-03-07 10:12:53 +01:00
|
|
|
--
|
2013-03-22 23:48:22 +01:00
|
|
|
1.8.1-rc2
|
2013-03-07 10:12:53 +01:00
|
|
|
|