diff --git a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java index fa9d56ec9..a0305a3c6 100644 --- a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java +++ b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java @@ -30,11 +30,13 @@ public class PanelItem { private boolean glow; private ItemMeta meta; private final boolean playerHead; + private String playerHeadName; private boolean invisible; public PanelItem(PanelItemBuilder builtItem) { this.icon = builtItem.getIcon(); this.playerHead = builtItem.isPlayerHead(); + this.playerHeadName = builtItem.getPlayerHeadName(); // Get the meta meta = icon.getItemMeta(); if (meta != null) { @@ -135,6 +137,13 @@ public class PanelItem { public boolean isPlayerHead() { return playerHead; } + + /** + * @return the playerHeadName + */ + public String getPlayerHeadName() { + return playerHeadName; + } /** * Click handler interface diff --git a/src/main/java/world/bentobox/bentobox/api/panels/builders/PanelItemBuilder.java b/src/main/java/world/bentobox/bentobox/api/panels/builders/PanelItemBuilder.java index ce6ea1098..011a9f1f3 100644 --- a/src/main/java/world/bentobox/bentobox/api/panels/builders/PanelItemBuilder.java +++ b/src/main/java/world/bentobox/bentobox/api/panels/builders/PanelItemBuilder.java @@ -20,6 +20,7 @@ public class PanelItemBuilder { private boolean glow = false; private PanelItem.ClickHandler clickHandler; private boolean playerHead; + private String playerHeadName; private boolean invisible; /** @@ -45,7 +46,7 @@ public class PanelItemBuilder { */ public PanelItemBuilder icon(String playerName) { this.icon = new ItemStack(Material.PLAYER_HEAD, 1); - this.name = playerName; + this.playerHeadName = playerName; this.playerHead = true; return this; } @@ -149,6 +150,13 @@ public class PanelItemBuilder { public boolean isPlayerHead() { return playerHead; } + + /** + * @return the playerHead + */ + public String getPlayerHeadName() { + return playerHeadName; + } /** * @return the invisible diff --git a/src/main/java/world/bentobox/bentobox/util/heads/HeadGetter.java b/src/main/java/world/bentobox/bentobox/util/heads/HeadGetter.java index 55e9093c6..171eca0ed 100644 --- a/src/main/java/world/bentobox/bentobox/util/heads/HeadGetter.java +++ b/src/main/java/world/bentobox/bentobox/util/heads/HeadGetter.java @@ -62,16 +62,16 @@ public class HeadGetter { */ public static void getHead(PanelItem panelItem, HeadRequester requester) { // Check if in cache - if (cachedHeads.containsKey(panelItem.getName())) { - panelItem.setHead(cachedHeads.get(panelItem.getName()).clone()); + if (cachedHeads.containsKey(panelItem.getPlayerHeadName())) { + panelItem.setHead(cachedHeads.get(panelItem.getPlayerHeadName()).clone()); requester.setHead(panelItem); } else { // Get the name - headRequesters.putIfAbsent(panelItem.getName(), new HashSet<>()); - Set requesters = headRequesters.get(panelItem.getName()); + headRequesters.putIfAbsent(panelItem.getPlayerHeadName(), new HashSet<>()); + Set requesters = headRequesters.get(panelItem.getPlayerHeadName()); requesters.add(requester); - headRequesters.put(panelItem.getName(), requesters); - names.put(panelItem.getName(), panelItem); + headRequesters.put(panelItem.getPlayerHeadName(), requesters); + names.put(panelItem.getPlayerHeadName(), panelItem); } }