Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/main/java/de/j/stationofdoom/util/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public ItemBuilder addFlags(ItemFlag ... itemFlags) {
return this;
}

/**
* Creates a PLAYER_HEAD ItemStack and, if a texture `url` is provided, applies it as the head's skin texture.
*
* @param url the texture value to assign to the head's `textures` property (typically a base64-encoded texture payload); if empty, the default head is returned
* @param name the name to associate with the underlying GameProfile used for the head
* @return an ItemStack representing the player head with the specified texture applied, or a default player head if `url` is empty
*/
public static ItemStack createHead(String url, String name) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD, (short) 1);
if (url.isEmpty())
Expand All @@ -103,6 +110,13 @@ public static ItemStack createHead(String url, String name) {
return head;
}

/**
* Initializes this builder's item as a player head and applies the given skin texture and profile name.
*
* @param url the skin texture value to apply to the head (if empty, the method returns null)
* @param name the profile name to associate with the head's GameProfile
* @return the current ItemBuilder configured as a PLAYER_HEAD with the specified texture and name, or `null` if `url` is empty
*/
public ItemBuilder getHeadBuilder(String url, String name) {
item = new ItemStack(Material.PLAYER_HEAD, (short) 1);
if (url.isEmpty())
Expand Down Expand Up @@ -133,4 +147,4 @@ public static ItemStack getHead(String name) {
Main.getMainLogger().severe("An error appeared in while getting a head");
return null;
}
}
}