use of org.bukkit.inventory.meta.SkullMeta in project MagicPlugin by elBukkit.
the class ShrinkSpell method dropHead.
protected void dropHead(Location location, String ownerName, String itemName, byte data) {
ItemStack shrunkenHead = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, data);
ItemMeta meta = shrunkenHead.getItemMeta();
if (itemName != null) {
meta.setDisplayName(itemName);
}
if (meta instanceof SkullMeta && ownerName != null) {
SkullMeta skullData = (SkullMeta) meta;
skullData.setOwner(ownerName);
}
shrunkenHead.setItemMeta(meta);
location.getWorld().dropItemNaturally(location, shrunkenHead);
}
use of org.bukkit.inventory.meta.SkullMeta in project MagicPlugin by elBukkit.
the class MaterialAndData method applyToItem.
@Override
public ItemStack applyToItem(ItemStack stack) {
stack.setType(material);
if (data != null) {
stack.setDurability(data);
}
if (material == Material.SKULL_ITEM) {
ItemMeta meta = stack.getItemMeta();
if (meta != null && meta instanceof SkullMeta && extraData != null && extraData instanceof BlockSkull) {
BlockSkull skullData = (BlockSkull) extraData;
if (skullData.skullType == SkullType.PLAYER && skullData.profile != null) {
SkullMeta skullMeta = (SkullMeta) meta;
InventoryUtils.setSkullProfile(skullMeta, ((BlockSkull) extraData).profile);
stack.setItemMeta(meta);
} else if (skullData.skullType == SkullType.PLAYER && skullData.playerName != null) {
SkullMeta skullMeta = (SkullMeta) meta;
skullMeta.setOwner(skullData.playerName);
stack.setItemMeta(meta);
}
}
} else if (material == Material.STANDING_BANNER || material == Material.WALL_BANNER || material == Material.BANNER) {
ItemMeta meta = stack.getItemMeta();
if (meta != null && meta instanceof BannerMeta && extraData != null && extraData instanceof BlockBanner) {
BannerMeta banner = (BannerMeta) meta;
BlockBanner bannerData = (BlockBanner) extraData;
if (bannerData.patterns != null) {
banner.setPatterns(bannerData.patterns);
}
if (bannerData.baseColor != null) {
banner.setBaseColor(bannerData.baseColor);
}
stack.setItemMeta(meta);
}
} else if (this.material == Material.LEATHER_BOOTS || this.material == Material.LEATHER_CHESTPLATE || this.material == Material.LEATHER_HELMET || this.material == Material.LEATHER_LEGGINGS) {
ItemMeta meta = stack.getItemMeta();
if (extraData != null && extraData instanceof LeatherArmorData && meta != null && meta instanceof LeatherArmorMeta) {
((LeatherArmorMeta) meta).setColor(((LeatherArmorData) extraData).getColor());
stack.setItemMeta(meta);
}
}
return stack;
}
use of org.bukkit.inventory.meta.SkullMeta in project TriggerReactor by wysohn.
the class CommonFunctions method headForName.
/**
* Create a player head with given name.
*
* <p>
* Example) /trg run #GIVE headForName("wysohn")
* </p>
*
* @param targetName
* name of the owner of head
* @return the ItemStack head
*/
public ItemStack headForName(String targetName) {
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta IM = head.getItemMeta();
SkullMeta SM = (SkullMeta) IM;
SM.setOwner(targetName);
head.setItemMeta(SM);
return head;
}
use of org.bukkit.inventory.meta.SkullMeta in project TriggerReactor by wysohn.
the class CommonFunctions method headForValue.
/**
* Create a player head with given textureValue(base64 encoded).
*
* <p>
* Example) /trg run #GIVE
* headForValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlc
* y5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RjZDdkZjUyNjQ1YzY4Y2RhZDg1NDhlNjFiM2Y3
* NjU5NjQwNzcyMjZiYTg3MmI5ZDJiZDQ1YzQz<b>OWQifX19\\</b>")
* </p>
* <p>
* <b> Notice that there is an extra \ sign as \ is an escape sequence. The final
* String will be ...OWQifX19\ instead of ...OWQifX19\\" </b>
* </p>
*
* @param textureValue
* base64 encoded texture value
* @return the ItemStack head
*/
public ItemStack headForValue(String textureValue) {
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta IM = head.getItemMeta();
SkullMeta SM = (SkullMeta) IM;
try {
SkullUtil.setTextureValue(SM, textureValue);
} catch (Exception e) {
// e.printStackTrace();
return head;
}
head.setItemMeta(SM);
return head;
}
use of org.bukkit.inventory.meta.SkullMeta in project askyblock by tastybento.
the class TopTen method getSkull.
ItemStack getSkull(int rank, Long long1, UUID player) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Getting the skull");
String playerName = plugin.getPlayers().getName(player);
if (DEBUG) {
plugin.getLogger().info("DEBUG: playername = " + playerName);
plugin.getLogger().info("DEBUG: second chance = " + plugin.getPlayers().getName(player));
}
ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
if (playerName == null)
return null;
SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
if (topTenHeads.containsKey(player)) {
playerSkull = topTenHeads.get(player);
meta = (SkullMeta) playerSkull.getItemMeta();
}
meta.setDisplayName((plugin.myLocale(player).topTenGuiHeading.replace("[name]", plugin.getGrid().getIslandName(player))).replace("[rank]", String.valueOf(rank)));
// meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + "<!> " + ChatColor.YELLOW + "Island: " + ChatColor.GOLD + ChatColor.UNDERLINE + plugin.getGrid().getIslandName(player) + ChatColor.GRAY + " (#" + rank + ")");
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.YELLOW + plugin.myLocale(player).levelislandLevel + " " + long1);
if (plugin.getPlayers().inTeam(player)) {
final List<UUID> pMembers = plugin.getPlayers().getMembers(player);
// Need to make this a vertical list, because some teams are very large and it'll go off the screen otherwise
List<String> memberList = new ArrayList<>();
for (UUID members : pMembers) {
memberList.add(ChatColor.AQUA + plugin.getPlayers().getName(members));
}
lore.addAll(memberList);
}
meta.setLore(lore);
playerSkull.setItemMeta(meta);
return playerSkull;
}
Aggregations