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:
17
paper-server/src/main/java/org/spigotmc/AsyncCatcher.java
Normal file
17
paper-server/src/main/java/org/spigotmc/AsyncCatcher.java
Normal 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 + "!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user