From 64ed155dc6ee5a302767e8f4438788d8050334e6 Mon Sep 17 00:00:00 2001 From: sovdee <10354869+sovdeeth@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:02:23 -0500 Subject: [PATCH] Require skull texture lookup on paper servers (#7152) * require skull texture lookup on paper servers * 1.19.4+ --- src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java b/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java index a74a604664d..e447300d6ef 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java @@ -21,6 +21,7 @@ import ch.njol.skript.Skript; import ch.njol.skript.aliases.ItemType; import ch.njol.skript.util.slot.Slot; +import com.destroystokyo.paper.profile.PlayerProfile; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -49,6 +50,8 @@ public class ItemUtils { // Introduced in Paper 1.21 public static final boolean HAS_RESET = Skript.methodExists(Damageable.class, "resetDamage"); public static final boolean CAN_CREATE_PLAYER_PROFILE = Skript.methodExists(Bukkit.class, "createPlayerProfile", UUID.class, String.class); + // paper does not do texture lookups by default + public static final boolean REQUIRES_TEXTURE_LOOKUP = Skript.classExists("com.destroystokyo.paper.profile.PlayerProfile") && Skript.isRunningMinecraft(1, 19, 4); /** * Gets damage/durability of an item, or 0 if it does not have damage. @@ -165,7 +168,12 @@ public static void setHeadOwner(ItemType skull, OfflinePlayer player) { SkullMeta skullMeta = (SkullMeta) meta; - if (player.getName() != null) { + if (REQUIRES_TEXTURE_LOOKUP) { + PlayerProfile profile = player.getPlayerProfile(); + if (!profile.hasTextures()) + profile.complete(true); // BLOCKING MOJANG API CALL + skullMeta.setPlayerProfile(profile); + } else if (player.getName() != null) { skullMeta.setOwningPlayer(player); } else if (CAN_CREATE_PLAYER_PROFILE) { //noinspection deprecation