Skip to content

Commit

Permalink
version bump minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LupusVirtute committed Nov 8, 2022
1 parent 0b6d4e4 commit 965bafc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.spacemc</groupId>
<artifactId>SpaceUtils</artifactId>
<version>1.0.10</version>
<version>1.0.11</version>
<packaging>jar</packaging>

<name>SpaceUtils</name>
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/org/spacemc/utils/item/ItemBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*
Expand Down

0 comments on commit 965bafc

Please sign in to comment.