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

@@ -228,6 +228,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
Preconditions.checkState(!this.entity.generation, "Cannot get nearby entities during world generation");
org.spigotmc.AsyncCatcher.catchOp("getNearbyEntities"); // Spigot
List<Entity> notchEntityList = this.entity.level().getEntities(this.entity, this.entity.getBoundingBox().inflate(x, y, z), Predicates.alwaysTrue());
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());

View File

@@ -492,6 +492,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void kickPlayer(String message) {
org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot
this.getHandle().transferCookieConnection.kickPlayer(CraftChatMessage.fromStringOrEmpty(message, true));
}