Search in sources :

Example 96 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.

the class SpecialItem method getItemStack.

public ItemStack getItemStack() {
    ItemStack itemStack;
    if (data != null) {
        itemStack = new ItemStack(getMaterial(), 1, getData());
    } else {
        itemStack = new ItemStack(getMaterial());
    }
    ItemMeta im = itemStack.getItemMeta();
    im.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.getDisplayName()));
    im.setLore(Arrays.asList(lore));
    itemStack.setItemMeta(im);
    return itemStack;
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 97 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.

the class AdminCommands method setItemPrice.

public void setItemPrice(CommandSender sender, String price) {
    if (checkSenderIsConsole(sender))
        return;
    if (!hasPermission(sender, "villagedefense.admin.setprice"))
        return;
    Player player = (Player) sender;
    ItemStack item = player.getItemInHand();
    if (item == null || item.getType().equals(Material.AIR)) {
        player.sendMessage(ChatColor.RED + "You must hold any item!");
        return;
    }
    // check any price from lore
    if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
        ItemMeta meta = item.getItemMeta();
        List<String> lore = item.getItemMeta().getLore();
        for (String search : lore) {
            if (search.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"))) {
                lore.remove(search);
                break;
            }
        }
        lore.add(0, ChatColor.GOLD + price + " " + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"));
        meta.setLore(lore);
        item.setItemMeta(meta);
        player.sendMessage(ChatColor.GREEN + "Command succesfully executed, item updated!");
    } else {
        Util.addLore(item, ChatColor.GOLD + price + " " + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"));
        player.sendMessage(ChatColor.GREEN + "Command succesfully executed!");
    }
}
Also used : Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 98 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.

the class Kit method setItemNameAndLore.

protected ItemStack setItemNameAndLore(ItemStack item, String name, String[] lore) {
    ItemMeta im = item.getItemMeta();
    im.setDisplayName(name);
    im.setLore(Arrays.asList(lore));
    item.setItemMeta(im);
    return item;
}
Also used : ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 99 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Village_Defense by Plajer.

the class Util method addLore.

public static void addLore(ItemStack itemStack, String string) {
    ItemMeta meta = itemStack.getItemMeta();
    List<String> lore = new ArrayList<>();
    if (meta != null && meta.hasLore())
        lore.addAll(meta.getLore());
    lore.add(string);
    meta.setLore(lore);
    itemStack.setItemMeta(meta);
}
Also used : ArrayList(java.util.ArrayList) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 100 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project TriggerReactor by wysohn.

the class InventoryTriggerManager method getColoredItem.

/**
 * @param item
 * @return copy of colored item
 */
private ItemStack getColoredItem(ItemStack item) {
    item = item.clone();
    ItemMeta IM = item.getItemMeta();
    if (IM != null) {
        if (IM.hasDisplayName()) {
            IM.setDisplayName(ChatColor.translateAlternateColorCodes('&', IM.getDisplayName()));
        }
        if (IM.hasLore()) {
            List<String> lore = new ArrayList<>(IM.getLore());
            for (int i = 0; i < IM.getLore().size(); i++) {
                lore.set(i, ChatColor.translateAlternateColorCodes('&', IM.getLore().get(i)));
            }
            IM.setLore(lore);
        }
        item.setItemMeta(IM);
    }
    return item;
}
Also used : ArrayList(java.util.ArrayList) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Aggregations

ItemMeta (org.bukkit.inventory.meta.ItemMeta)361 ItemStack (org.bukkit.inventory.ItemStack)205 ArrayList (java.util.ArrayList)87 Player (org.bukkit.entity.Player)45 Inventory (org.bukkit.inventory.Inventory)33 Map (java.util.Map)29 Enchantment (org.bukkit.enchantments.Enchantment)23 EventHandler (org.bukkit.event.EventHandler)23 SkullMeta (org.bukkit.inventory.meta.SkullMeta)22 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)20 ListTag (com.wasteofplastic.org.jnbt.ListTag)20 StringTag (com.wasteofplastic.org.jnbt.StringTag)20 Tag (com.wasteofplastic.org.jnbt.Tag)20 PlayerInventory (org.bukkit.inventory.PlayerInventory)17 IOException (java.io.IOException)15 Material (org.bukkit.Material)14 PotionMeta (org.bukkit.inventory.meta.PotionMeta)14 Mage (com.elmakers.mine.bukkit.api.magic.Mage)12 BookMeta (org.bukkit.inventory.meta.BookMeta)12 List (java.util.List)11