From c349a2493b264b4f648257f70a126e5045be17e6 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 30 Mar 2014 09:16:12 +1100 Subject: [PATCH] Prevent the inevitable server lag|crashes caused by people doing a blocking operation on the main thread. --- ...getOfflinePlayer-UUID-on-main-thread.patch | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 CraftBukkit-Patches/0125-Prevent-getOfflinePlayer-UUID-on-main-thread.patch diff --git a/CraftBukkit-Patches/0125-Prevent-getOfflinePlayer-UUID-on-main-thread.patch b/CraftBukkit-Patches/0125-Prevent-getOfflinePlayer-UUID-on-main-thread.patch new file mode 100644 index 0000000000..70a33f94c9 --- /dev/null +++ b/CraftBukkit-Patches/0125-Prevent-getOfflinePlayer-UUID-on-main-thread.patch @@ -0,0 +1,21 @@ +From 199e63f001def1fb39642d5f6448544493ec37c7 Mon Sep 17 00:00:00 2001 +From: md_5 +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 +