diff --git a/BuildMechanicsCore/build.gradle.kts b/BuildMechanicsCore/build.gradle.kts index 3a871d9df..978c520ac 100644 --- a/BuildMechanicsCore/build.gradle.kts +++ b/BuildMechanicsCore/build.gradle.kts @@ -1,7 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar description = "Library plugin for WeaponMechanics" -version = "1.3.5-BETA" +version = "1.3.6-BETA" plugins { `maven-publish` diff --git a/BuildWeaponMechanics/build.gradle.kts b/BuildWeaponMechanics/build.gradle.kts index 24a253bf2..bbeaae8e3 100644 --- a/BuildWeaponMechanics/build.gradle.kts +++ b/BuildWeaponMechanics/build.gradle.kts @@ -2,7 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.minecrell.pluginyml.bukkit.BukkitPluginDescription description = "A New Age of Weapons in Minecraft" -version = "1.8.3-BETA" +version = "1.8.4-BETA" plugins { id("me.deecaad.java-conventions") diff --git a/MechanicsCore/src/main/java/me/deecaad/core/file/serializers/ItemSerializer.java b/MechanicsCore/src/main/java/me/deecaad/core/file/serializers/ItemSerializer.java index d150baf00..2d08a7d73 100644 --- a/MechanicsCore/src/main/java/me/deecaad/core/file/serializers/ItemSerializer.java +++ b/MechanicsCore/src/main/java/me/deecaad/core/file/serializers/ItemSerializer.java @@ -1,5 +1,7 @@ package me.deecaad.core.file.serializers; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; import me.deecaad.core.MechanicsCore; import me.deecaad.core.compatibility.CompatibilityAPI; import me.deecaad.core.compatibility.nbt.NBTCompatibility; @@ -167,14 +169,33 @@ public ItemStack serializeWithoutRecipe(SerializeData data) throws SerializerExc String owningPlayer = data.of("Skull_Owning_Player").assertType(String.class).get(null); if (owningPlayer != null) { try { + int splitIndex = owningPlayer.indexOf(" "); + String id = splitIndex == -1 ? owningPlayer : owningPlayer.substring(0, splitIndex); + String url = splitIndex == -1 ? null : owningPlayer.substring(splitIndex + 1); + SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta(); + UUID uuid; try { - uuid = UUID.fromString(owningPlayer); + uuid = UUID.fromString(id); } catch (IllegalArgumentException e) { uuid = null; } - if (uuid != null) { + + // Custom skull format... "UUID URL" + // "970e0a59-b95d-45a9-9039-b43ac4fbfc7c https://textures.minecraft.net/texture/a0564817fcc8dd51bc1957c0b7ea142db687dd6f1caafd35bb4dcfee592421c" + // https://www.spigotmc.org/threads/create-a-skull-item-stack-with-a-custom-texture-base64.82416/ + if (uuid != null && url != null) { + GameProfile dummy = new GameProfile(uuid, null); + byte[] encoded = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes()); + dummy.getProperties().put("textures", new Property("textures", new String(encoded))); + + Field field = ReflectionUtil.getField(skullMeta.getClass(), GameProfile.class); + ReflectionUtil.setField(field, skullMeta, dummy); + } + + // Standard player name SkullMeta... "CJCrafter", "DeeCaaD", "Darkman_Bree" + else if (uuid != null) { if (CompatibilityAPI.getVersion() >= 1.12) { skullMeta.setOwningPlayer(Bukkit.getServer().getOfflinePlayer(uuid)); } else {