mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Added support for player heads in PanelItemBuilder API
This commit is contained in:
parent
f14676f5c6
commit
7f0d71e25c
@ -3,10 +3,12 @@ package us.tastybento.bskyblock.api.panels.builders;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||||
import us.tastybento.bskyblock.api.panels.PanelItem.ClickHandler;
|
import us.tastybento.bskyblock.api.panels.PanelItem.ClickHandler;
|
||||||
@ -28,6 +30,31 @@ public class PanelItemBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set icon to player's head
|
||||||
|
* @param playerUUID - player's UUID
|
||||||
|
* @return PanelItemBuilder
|
||||||
|
*/
|
||||||
|
public PanelItemBuilder icon(UUID playerUUID) {
|
||||||
|
return icon(Bukkit.getOfflinePlayer(playerUUID).getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set icon to player's head
|
||||||
|
* @param playerName - player's name
|
||||||
|
* @return PanelItemBuilder
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public PanelItemBuilder icon(String playerName) {
|
||||||
|
ItemStack item = new ItemStack(Material.SKULL_ITEM,1,(short)3);
|
||||||
|
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||||
|
// This is deprecated, but apparently the only way to make it work right now
|
||||||
|
meta.setOwner(playerName);
|
||||||
|
item.setItemMeta( meta );
|
||||||
|
this.icon = item;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PanelItemBuilder name(String name) {
|
public PanelItemBuilder name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
@ -59,9 +86,6 @@ public class PanelItemBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PanelItem build() {
|
public PanelItem build() {
|
||||||
if (icon == null) {
|
|
||||||
Bukkit.getLogger().info("DEBUG: icon is null");
|
|
||||||
}
|
|
||||||
return new PanelItem(icon, name, description, glow, clickHandler);
|
return new PanelItem(icon, name, description, glow, clickHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user