Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public interface ClickHandler {
public void setHead(ItemStack itemStack) {
// update amount before replacing.
itemStack.setAmount(this.icon.getAmount());
ItemMeta originalMeta = this.icon.getItemMeta();

this.icon = itemStack;

// Get the meta
Expand All @@ -203,6 +205,11 @@ public void setHead(ItemStack itemStack) {
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);

if (originalMeta != null && originalMeta.hasCustomModelDataComponent()) {
meta.setCustomModelDataComponent(originalMeta.getCustomModelDataComponent());
}

icon.setItemMeta(meta);
}
// Create the final item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,27 @@ public PanelItemBuilder icon(@Nullable ItemStack icon) {
return this;
}


/**
* Assigns icon and player name to the panel item.
* @param playerName the name of player head icon.
* @param icon the original player head icon
* @return PanelItemBuilder
*/
public PanelItemBuilder icon(String playerName, ItemStack icon) {
this.icon = icon;
this.playerHeadName = playerName;
return this;
}


/**
* Set icon to player's head
* @param playerName - player's name
* @return PanelItemBuilder
*/
public PanelItemBuilder icon(String playerName) {
this.icon = new ItemStack(Material.PLAYER_HEAD);
this.playerHeadName = playerName;
return this;
return this.icon(playerName, new ItemStack(Material.PLAYER_HEAD));
}

public PanelItemBuilder name(@Nullable String name) {
Expand Down