Prevent the inevitable server lag|crashes caused by people doing a blocking operation on the main thread.

This commit is contained in:
md_5 2014-03-30 09:16:12 +11:00
parent f5167c9e46
commit c349a2493b

View file

@ -0,0 +1,21 @@
From 199e63f001def1fb39642d5f6448544493ec37c7 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sun, 30 Mar 2014 09:15:35 +1100
Subject: [PATCH] Prevent getOfflinePlayer(UUID) on main thread.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4c089ea..8961015 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1341,6 +1341,7 @@ public final class CraftServer implements Server {
// TODO: In 1.7.6+ this should just lookup the UUID-based player data filename
public OfflinePlayer getOfflinePlayer(UUID id) {
+ com.google.common.base.Preconditions.checkState(!Bukkit.isPrimaryThread(), "Cannot call getOfflinePlayer(UUID) on main thread, this operation is blocking!"); // Spigot
String name = MojangNameLookup.lookupName(id);
if (name == null) {
// This is completely wrong
--
1.8.3.2