diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java index ce129231dd..e1aa6ca742 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java @@ -4427,8 +4427,10 @@ public void adjust(Mechanism mechanism) { else { profile = new PlayerProfile(idString, null, texture); } - profile = NMSHandler.instance.fillPlayerProfile(profile); - if (texture != null) { // Ensure we didn't get overwritten + if (texture == null || profile.getName() == null || profile.getUniqueId() == null) { // Load if needed + profile = NMSHandler.instance.fillPlayerProfile(profile); + } + if (texture != null) { profile.setTexture(texture); } NMSHandler.blockHelper.setPlayerProfile((Skull) blockState, profile); diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemSkullskin.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemSkullskin.java index e362d98fae..38f9e2eb46 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemSkullskin.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/item/ItemSkullskin.java @@ -170,8 +170,10 @@ public void adjust(Mechanism mechanism) { else { profile = new PlayerProfile(idString, null, texture); } - profile = NMSHandler.instance.fillPlayerProfile(profile); - if (texture != null) { // Ensure we didn't get overwritten + if (texture == null || profile.getName() == null || profile.getUniqueId() == null) { // Load if needed + profile = NMSHandler.instance.fillPlayerProfile(profile); + } + if (texture != null) { profile.setTexture(texture); } if (profile.getTexture() == null) { diff --git a/v1_18/src/main/java/com/denizenscript/denizen/nms/v1_18/Handler.java b/v1_18/src/main/java/com/denizenscript/denizen/nms/v1_18/Handler.java index ec9d58f9c7..80873c0478 100644 --- a/v1_18/src/main/java/com/denizenscript/denizen/nms/v1_18/Handler.java +++ b/v1_18/src/main/java/com/denizenscript/denizen/nms/v1_18/Handler.java @@ -131,44 +131,33 @@ public BlockLight createBlockLight(Location location, int lightLevel, long ticks @Override public PlayerProfile fillPlayerProfile(PlayerProfile playerProfile) { + if (playerProfile == null) { + return null; + } + if (playerProfile.getName() == null && playerProfile.getUniqueId() == null) { + return playerProfile; // Cannot fill without lookup data + } + if (playerProfile.hasTexture() && playerProfile.hasTextureSignature() && playerProfile.getName() != null && playerProfile.getUniqueId() != null) { + return playerProfile; // Already filled + } try { - if (playerProfile != null) { - GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName()); - gameProfile.getProperties().get("textures").clear(); - if (playerProfile.getTextureSignature() != null) { - gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature())); - } - else { - gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture())); - } - MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer(); - GameProfile gameProfile1 = null; - if (gameProfile.getId() != null) { - gameProfile1 = minecraftServer.getProfileCache().get(gameProfile.getId()).orElse(null); - } - if (gameProfile1 == null && gameProfile.getName() != null) { - gameProfile1 = minecraftServer.getProfileCache().get(gameProfile.getName()).orElse(null); - } - if (gameProfile1 == null) { - gameProfile1 = gameProfile; - } - if (playerProfile.hasTexture()) { - gameProfile1.getProperties().get("textures").clear(); - if (playerProfile.getTextureSignature() != null) { - gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature())); - } - else { - gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture())); - } - } - if (Iterables.getFirst(gameProfile1.getProperties().get("textures"), null) == null) { - gameProfile1 = minecraftServer.getSessionService().fillProfileProperties(gameProfile1, true); - } - Property property = Iterables.getFirst(gameProfile1.getProperties().get("textures"), null); - return new PlayerProfile(gameProfile1.getName(), gameProfile1.getId(), - property != null ? property.getValue() : null, - property != null ? property.getSignature() : null); + GameProfile profile = null; + MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer(); + if (playerProfile.getUniqueId() != null) { + profile = minecraftServer.getProfileCache().get(playerProfile.getUniqueId()).orElse(null); + } + if (profile == null && playerProfile.getName() != null) { + profile = minecraftServer.getProfileCache().get(playerProfile.getName()).orElse(null); + } + if (profile == null) { + profile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName()); + } + Property textures = profile.getProperties().containsKey("textures") ? Iterables.getFirst(profile.getProperties().get("textures"), null) : null; + if (textures == null || !textures.hasSignature() || profile.getName() == null || profile.getId() == null) { + profile = minecraftServer.getSessionService().fillProfileProperties(profile, true); + textures = profile.getProperties().containsKey("textures") ? Iterables.getFirst(profile.getProperties().get("textures"), null) : null; } + return new PlayerProfile(profile.getName(), profile.getId(), textures == null ? null : textures.getValue(), textures == null ? null : textures.getSignature()); } catch (Exception e) { if (CoreConfiguration.debugVerbose) {