mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 11:15:24 +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 boolean glow;
|
||||||
private ItemMeta meta;
|
private ItemMeta meta;
|
||||||
private final boolean playerHead;
|
private final boolean playerHead;
|
||||||
|
private String playerHeadName;
|
||||||
private boolean invisible;
|
private boolean invisible;
|
||||||
|
|
||||||
public PanelItem(PanelItemBuilder builtItem) {
|
public PanelItem(PanelItemBuilder builtItem) {
|
||||||
this.icon = builtItem.getIcon();
|
this.icon = builtItem.getIcon();
|
||||||
this.playerHead = builtItem.isPlayerHead();
|
this.playerHead = builtItem.isPlayerHead();
|
||||||
|
this.playerHeadName = builtItem.getPlayerHeadName();
|
||||||
// Get the meta
|
// Get the meta
|
||||||
meta = icon.getItemMeta();
|
meta = icon.getItemMeta();
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
@ -136,6 +138,13 @@ public class PanelItem {
|
|||||||
return playerHead;
|
return playerHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the playerHeadName
|
||||||
|
*/
|
||||||
|
public String getPlayerHeadName() {
|
||||||
|
return playerHeadName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Click handler interface
|
* Click handler interface
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,7 @@ public class PanelItemBuilder {
|
|||||||
private boolean glow = false;
|
private boolean glow = false;
|
||||||
private PanelItem.ClickHandler clickHandler;
|
private PanelItem.ClickHandler clickHandler;
|
||||||
private boolean playerHead;
|
private boolean playerHead;
|
||||||
|
private String playerHeadName;
|
||||||
private boolean invisible;
|
private boolean invisible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +46,7 @@ public class PanelItemBuilder {
|
|||||||
*/
|
*/
|
||||||
public PanelItemBuilder icon(String playerName) {
|
public PanelItemBuilder icon(String playerName) {
|
||||||
this.icon = new ItemStack(Material.PLAYER_HEAD, 1);
|
this.icon = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
this.name = playerName;
|
this.playerHeadName = playerName;
|
||||||
this.playerHead = true;
|
this.playerHead = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -150,6 +151,13 @@ public class PanelItemBuilder {
|
|||||||
return playerHead;
|
return playerHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the playerHead
|
||||||
|
*/
|
||||||
|
public String getPlayerHeadName() {
|
||||||
|
return playerHeadName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the invisible
|
* @return the invisible
|
||||||
*/
|
*/
|
||||||
|
@ -62,16 +62,16 @@ public class HeadGetter {
|
|||||||
*/
|
*/
|
||||||
public static void getHead(PanelItem panelItem, HeadRequester requester) {
|
public static void getHead(PanelItem panelItem, HeadRequester requester) {
|
||||||
// Check if in cache
|
// Check if in cache
|
||||||
if (cachedHeads.containsKey(panelItem.getName())) {
|
if (cachedHeads.containsKey(panelItem.getPlayerHeadName())) {
|
||||||
panelItem.setHead(cachedHeads.get(panelItem.getName()).clone());
|
panelItem.setHead(cachedHeads.get(panelItem.getPlayerHeadName()).clone());
|
||||||
requester.setHead(panelItem);
|
requester.setHead(panelItem);
|
||||||
} else {
|
} else {
|
||||||
// Get the name
|
// Get the name
|
||||||
headRequesters.putIfAbsent(panelItem.getName(), new HashSet<>());
|
headRequesters.putIfAbsent(panelItem.getPlayerHeadName(), new HashSet<>());
|
||||||
Set<HeadRequester> requesters = headRequesters.get(panelItem.getName());
|
Set<HeadRequester> requesters = headRequesters.get(panelItem.getPlayerHeadName());
|
||||||
requesters.add(requester);
|
requesters.add(requester);
|
||||||
headRequesters.put(panelItem.getName(), requesters);
|
headRequesters.put(panelItem.getPlayerHeadName(), requesters);
|
||||||
names.put(panelItem.getName(), panelItem);
|
names.put(panelItem.getPlayerHeadName(), panelItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user