From 4886fbd3ccc4b1b3b7019ca6fa5035624bf49d8a Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 13 Jan 2018 12:29:50 -0500 Subject: [PATCH] Fix SPIGOT-3764 - Fixes deadlock with Skull Owner changes --- .../0262-Fix-SPIGOT-3764.patch | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Spigot-Server-Patches/0262-Fix-SPIGOT-3764.patch diff --git a/Spigot-Server-Patches/0262-Fix-SPIGOT-3764.patch b/Spigot-Server-Patches/0262-Fix-SPIGOT-3764.patch new file mode 100644 index 0000000000..d95c19afa4 --- /dev/null +++ b/Spigot-Server-Patches/0262-Fix-SPIGOT-3764.patch @@ -0,0 +1,79 @@ +From d68b88f5e1ce7b338a070ef7c1261c621a009253 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sat, 13 Jan 2018 12:26:37 -0500 +Subject: [PATCH] Fix SPIGOT-3764 + + +diff --git a/src/main/java/net/minecraft/server/ItemSkull.java b/src/main/java/net/minecraft/server/ItemSkull.java +index f19acf9ba..06fb9886e 100644 +--- a/src/main/java/net/minecraft/server/ItemSkull.java ++++ b/src/main/java/net/minecraft/server/ItemSkull.java +@@ -143,7 +143,7 @@ public class ItemSkull extends Item { + nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile)); + return false; + } +- }); ++ }, true); // Paper + // Spigot end + return true; + } else { +diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java +index ba02a17e0..8c30b1965 100644 +--- a/src/main/java/net/minecraft/server/TileEntitySkull.java ++++ b/src/main/java/net/minecraft/server/TileEntitySkull.java +@@ -182,12 +182,13 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa + } + return false; + } +- }); ++ }, true); // Paper + // Spigot end + } + + // Spigot start - Support async lookups +- public static Future b(final GameProfile gameprofile, final Predicate callback) { ++ // Paper - temp fixes until spigot fixes it ++ public static Future b(final GameProfile gameprofile, final Predicate callback, boolean doAsync) { + if (gameprofile != null && !UtilColor.b(gameprofile.getName())) { + if (gameprofile.isComplete() && gameprofile.getProperties().containsKey("textures")) { + callback.apply(gameprofile); +@@ -199,7 +200,7 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa + callback.apply(profile); + + return Futures.immediateFuture(profile); +- } else { ++ } else if (doAsync) { + return executor.submit(new Callable() { + @Override + public GameProfile call() { +@@ -217,6 +218,14 @@ public class TileEntitySkull extends TileEntity /*implements ITickable*/ { // Pa + return profile; + } + }); ++ } else { ++ profile = skinCache.getUnchecked(gameprofile.getName().toLowerCase(java.util.Locale.ROOT)); ++ if (profile == null) { ++ callback.apply(gameprofile); ++ } else { ++ callback.apply(profile); ++ } ++ return Futures.immediateFuture(profile); + } + } + } else { +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +index 987cc9a80..a67419774 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +@@ -79,7 +79,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { + if (profile != null) { + // Fill in textures + // Must be done sync due to way client handles textures +- profile = com.google.common.util.concurrent.Futures.getUnchecked(TileEntitySkull.b(profile, com.google.common.base.Predicates.alwaysTrue())); // Spigot ++ profile = com.google.common.util.concurrent.Futures.getUnchecked(TileEntitySkull.b(profile, com.google.common.base.Predicates.alwaysTrue(), false)); // Spigot // Paper + + NBTTagCompound owner = new NBTTagCompound(); + GameProfileSerializer.serialize(owner, profile); +-- +2.15.1 +