From c7ec6108fc14e7f6e58167610d52cacbecd266a1 Mon Sep 17 00:00:00 2001 From: JRoy <10731363+JRoy@users.noreply.github.com> Date: Sat, 28 Jun 2025 17:14:48 -0700 Subject: [PATCH 1/2] Fix /skull issues on 1.20.4+ --- .../essentials/commands/Commandskull.java | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java index e491a22f7a9..23f40d14839 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java @@ -9,6 +9,7 @@ import com.google.gson.JsonParser; import net.ess3.api.TranslatableException; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; @@ -108,7 +109,7 @@ private void editSkull(final User user, final User receive, final ItemStack stac ess.runTaskAsynchronously(() -> { // Run this stuff async because it causes an HTTP request - final String shortOwnerName; + String shortOwnerName; if (URL_VALUE_PATTERN.matcher(owner).matches()) { if (!playerProfileSupported) { user.sendTl("unsupportedFeature"); @@ -129,23 +130,46 @@ private void editSkull(final User user, final User receive, final ItemStack stac shortOwnerName = owner.substring(0, 7); } else { - //noinspection deprecation - skullMeta.setOwner(owner); - shortOwnerName = owner; + if (playerProfileSupported) { + try { + PlayerProfile profile = ess.getServer().createPlayerProfile(null, owner); + profile = profile.update().join(); + + if (profile != null) { + skullMeta.setOwnerProfile(profile); + } + if (skullMeta.getOwnerProfile() == null) { + OfflinePlayer offline = ess.getServer().getOfflinePlayer(owner); + skullMeta.setOwningPlayer(offline); + } + + shortOwnerName = owner; + } catch (final Exception e) { + //noinspection deprecation + skullMeta.setOwner(owner); + shortOwnerName = owner; + } + } else { + //noinspection deprecation + skullMeta.setOwner(owner); + shortOwnerName = owner; + } } skullMeta.setDisplayName("§fSkull of " + shortOwnerName); + final String shortNameFinal = shortOwnerName; + ess.scheduleSyncDelayedTask(() -> { stack.setItemMeta(skullMeta); if (spawn) { Inventories.addItem(receive.getBase(), stack); - receive.sendTl("givenSkull", shortOwnerName); + receive.sendTl("givenSkull", shortNameFinal); if (user != receive) { - user.sendTl("givenSkullOther", receive.getDisplayName(), shortOwnerName); + user.sendTl("givenSkullOther", receive.getDisplayName(), shortNameFinal); } return; } - user.sendTl("skullChanged", shortOwnerName); + user.sendTl("skullChanged", shortNameFinal); }); }); } From fd212d7cbaec69c85f4a6eb6474d8ee3290e2ffe Mon Sep 17 00:00:00 2001 From: JRoy <10731363+JRoy@users.noreply.github.com> Date: Sat, 28 Jun 2025 17:18:51 -0700 Subject: [PATCH 2/2] :tf: --- .../java/com/earth2me/essentials/commands/Commandskull.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java index 23f40d14839..1adcefe8f2e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java @@ -139,7 +139,7 @@ private void editSkull(final User user, final User receive, final ItemStack stac skullMeta.setOwnerProfile(profile); } if (skullMeta.getOwnerProfile() == null) { - OfflinePlayer offline = ess.getServer().getOfflinePlayer(owner); + final OfflinePlayer offline = ess.getServer().getOfflinePlayer(owner); skullMeta.setOwningPlayer(offline); }