File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
src/main/java/world/bentobox/bentobox/api/panels Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,8 @@ public interface ClickHandler {
193193 public void setHead (ItemStack itemStack ) {
194194 // update amount before replacing.
195195 itemStack .setAmount (this .icon .getAmount ());
196+ ItemMeta originalMeta = this .icon .getItemMeta ();
197+
196198 this .icon = itemStack ;
197199
198200 // Get the meta
@@ -203,6 +205,11 @@ public void setHead(ItemStack itemStack) {
203205 meta .addItemFlags (ItemFlag .HIDE_DESTROYS );
204206 meta .addItemFlags (ItemFlag .HIDE_PLACED_ON );
205207 meta .addItemFlags (ItemFlag .HIDE_ENCHANTS );
208+
209+ if (originalMeta != null && originalMeta .hasCustomModelDataComponent ()) {
210+ meta .setCustomModelDataComponent (originalMeta .getCustomModelDataComponent ());
211+ }
212+
206213 icon .setItemMeta (meta );
207214 }
208215 // Create the final item
Original file line number Diff line number Diff line change @@ -42,15 +42,27 @@ public PanelItemBuilder icon(@Nullable ItemStack icon) {
4242 return this ;
4343 }
4444
45+
46+ /**
47+ * Assigns icon and player name to the panel item.
48+ * @param playerName the name of player head icon.
49+ * @param icon the original player head icon
50+ * @return PanelItemBuilder
51+ */
52+ public PanelItemBuilder icon (String playerName , ItemStack icon ) {
53+ this .icon = icon ;
54+ this .playerHeadName = playerName ;
55+ return this ;
56+ }
57+
58+
4559 /**
4660 * Set icon to player's head
4761 * @param playerName - player's name
4862 * @return PanelItemBuilder
4963 */
5064 public PanelItemBuilder icon (String playerName ) {
51- this .icon = new ItemStack (Material .PLAYER_HEAD );
52- this .playerHeadName = playerName ;
53- return this ;
65+ return this .icon (playerName , new ItemStack (Material .PLAYER_HEAD ));
5466 }
5567
5668 public PanelItemBuilder name (@ Nullable String name ) {
You can’t perform that action at this time.
0 commit comments