Search in sources :

Example 86 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project TangledMazes by GorgeousOne.

the class TangledMain method isSelectionWand.

public static boolean isSelectionWand(ItemStack item) {
    if (item == null)
        return false;
    ItemMeta itemMeta = item.getItemMeta();
    ItemMeta wandmeta = wand.getItemMeta();
    return item.getType() == wand.getType() && itemMeta.getDisplayName() != null && itemMeta.getDisplayName().equals(wandmeta.getDisplayName());
}
Also used : ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 87 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Ublisk by Derkades.

the class UpdateBackpackName method run.

@Override
public void run() {
    // TODO Remove this when a new system is in place
    for (Player player : Bukkit.getOnlinePlayers()) {
        PlayerInventory inv = player.getInventory();
        if (inv.getItemInMainHand().getType() == Material.END_CRYSTAL) {
            inv.remove(Material.END_CRYSTAL);
            ItemStack item = new ItemStack(Material.END_CRYSTAL);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Backpack");
            item.setItemMeta(meta);
            int slot = inv.getHeldItemSlot();
            inv.setItem(slot, item);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) PlayerInventory(org.bukkit.inventory.PlayerInventory) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 88 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Ublisk by Derkades.

the class Item method setName.

public Item setName(String name) {
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(name);
    item.setItemMeta(meta);
    return this;
}
Also used : ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 89 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Fusion by GummyPvP.

the class ItemBuilder method lore.

/**
 * Set the lore of an ItemStack.
 *
 * @param lore - List(String) - lines of text to add to the ItemStack's lore.
 * @return current instance of ItemBuilder object.
 */
public ItemBuilder lore(List<String> lore) {
    ItemMeta im = item.getItemMeta();
    List<String> clone = new ArrayList<String>();
    for (String lores : lore) {
        clone.add(ChatColor.translateAlternateColorCodes('&', lores));
    }
    im.setLore(clone);
    item.setItemMeta(im);
    return this;
}
Also used : ArrayList(java.util.ArrayList) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 90 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project modules-extra by CubeEngine.

the class LogCommands method giveSelectionTool.

@SuppressWarnings("deprecation")
public static void giveSelectionTool(User user) {
    ItemStack found = null;
    for (ItemStack item : user.getInventory().getContents()) {
        if (item != null && item.getType() == WOOD_AXE && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(selectorToolName)) {
            found = item;
            break;
        }
    }
    if (found == null) {
        found = new ItemStack(WOOD_AXE, 1);
        ItemMeta meta = found.getItemMeta();
        meta.setDisplayName(selectorToolName);
        meta.setLore(Arrays.asList("created by " + user.getDisplayName()));
        found.setItemMeta(meta);
        ItemStack oldItemInHand = user.getItemInHand();
        user.setItemInHand(found);
        HashMap<Integer, ItemStack> tooMuch = user.getInventory().addItem(oldItemInHand);
        for (ItemStack item : tooMuch.values()) {
            user.getWorld().dropItemNaturally(user.getLocation(), item);
        }
        user.updateInventory();
        user.sendTranslated(POSITIVE, "Received a new Region-Selector Tool");
        return;
    }
    user.getInventory().removeItem(found);
    ItemStack oldItemInHand = user.getItemInHand();
    user.setItemInHand(found);
    user.getInventory().addItem(oldItemInHand);
    user.updateInventory();
    user.sendTranslated(POSITIVE, "Found a Region-Selector Tool in your inventory!");
}
Also used : ItemStack(org.spongepowered.api.item.inventory.ItemStack) 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