mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 03:05:16 +01:00
Added ability to have player heads with custom name (#1007)
* Added new attribute playerHeadName * Added method PanelItem#getPlayerHeadName() and PanelItemBuilder#getPlayerHeadName() * Added playerHeadName attribute * getPlayerHeadName instead of getName
This commit is contained in:
parent
551975d6c9
commit
87ea48443f
@ -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
|
||||
|
@ -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
|
||||
|
@ -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<HeadRequester> requesters = headRequesters.get(panelItem.getName());
|
||||
headRequesters.putIfAbsent(panelItem.getPlayerHeadName(), new HashSet<>());
|
||||
Set<HeadRequester> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user