diff --git a/pom.xml b/pom.xml
index efdb1fa..1660544 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.spacemc
SpaceUtils
- 1.0.10
+ 1.0.11
jar
SpaceUtils
diff --git a/src/main/java/org/spacemc/utils/item/ItemBuilder.kt b/src/main/java/org/spacemc/utils/item/ItemBuilder.kt
index 2a7c537..c2d35dd 100644
--- a/src/main/java/org/spacemc/utils/item/ItemBuilder.kt
+++ b/src/main/java/org/spacemc/utils/item/ItemBuilder.kt
@@ -421,6 +421,38 @@ class ItemBuilder {
return this
}
+ fun customTexture(texture: String): ItemBuilder {
+ var texture = texture
+ texture = "http://textures.minecraft.net/texture/$texture"
+ if (texture.isEmpty()) {
+ return this
+ }
+ val skullMeta: SkullMeta = this.meta() as SkullMeta
+ val profile = Bukkit.createProfile(UUID.randomUUID(), null)
+ val encodedData: ByteArray =
+ Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", texture).toByteArray())
+ profile.properties.add(ProfileProperty("textures", String(encodedData)))
+ var profileField: Field? = null
+ try {
+ profileField = skullMeta.javaClass.getDeclaredField("profile")
+ } catch (e: NoSuchFieldException) {
+ e.printStackTrace()
+ } catch (e: SecurityException) {
+ e.printStackTrace()
+ }
+ assert(profileField != null)
+ profileField!!.isAccessible = true
+ try {
+ profileField[skullMeta] = profile
+ } catch (e: IllegalArgumentException) {
+ e.printStackTrace()
+ } catch (e: IllegalAccessException) {
+ e.printStackTrace()
+ }
+ make().setItemMeta(skullMeta)
+ return this
+ }
+
/**
* Returns the [ItemMeta] of the [ItemStack]
*