Async Operation Catching

Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2014-03-25 16:10:01 +11:00
parent 973f52a650
commit 5240271410
12 changed files with 185 additions and 97 deletions

View File

@@ -0,0 +1,17 @@
package org.spigotmc;
import net.minecraft.server.MinecraftServer;
public class AsyncCatcher
{
public static boolean enabled = true;
public static void catchOp(String reason)
{
if ( AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread )
{
throw new IllegalStateException( "Asynchronous " + reason + "!" );
}
}
}