papermc/CraftBukkit-Patches/0125-Prevent-getOfflinePlayer-UUID-on-main-thread.patch

21 lines
1,003 B
Diff

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