Search in sources :

Example 6 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Denizen-For-Bukkit by DenizenScript.

the class ItemLore method adjust.

@Override
public void adjust(Mechanism mechanism) {
    if (mechanism.matches("lore")) {
        ItemMeta meta = item.getItemStack().getItemMeta();
        dList lore = mechanism.getValue().asType(dList.class);
        if (item.isItemscript()) {
            lore.add(0, ItemScriptHelper.createItemScriptID(item.getScriptName()));
        }
        for (int i = 0; i < lore.size(); i++) {
            lore.set(i, EscapeTags.unEscape(lore.get(i)));
        }
        meta.setLore(lore);
        item.getItemStack().setItemMeta(meta);
    }
}
Also used : net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 7 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Denizen-For-Bukkit by DenizenScript.

the class ItemPatterns method setPatterns.

private void setPatterns(List<Pattern> patterns) {
    ItemStack itemStack = item.getItemStack();
    ItemMeta itemMeta = itemStack.getItemMeta();
    if (itemMeta instanceof BlockStateMeta) {
        Banner banner = (Banner) ((BlockStateMeta) itemMeta).getBlockState();
        banner.setPatterns(patterns);
        banner.update();
        ((BlockStateMeta) itemMeta).setBlockState(banner);
    } else {
        ((BannerMeta) itemMeta).setPatterns(patterns);
    }
    itemStack.setItemMeta(itemMeta);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 8 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Denizen-For-Bukkit by DenizenScript.

the class InventoryMenuItem method setDescriptions.

public void setDescriptions(String... lines) {
    ItemMeta meta = item.getItemMeta();
    List<String> lore = new ArrayList<String>();
    for (String s : lines) {
        lore.addAll(Arrays.asList(Utilities.wrapWords(s, 24)));
    }
    meta.setLore(lore);
    item.setItemMeta(meta);
}
Also used : ArrayList(java.util.ArrayList) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 9 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Denizen-For-Bukkit by DenizenScript.

the class ItemChangeMessage method sendMessage.

public static void sendMessage(Player player, String message) {
    ItemStack item = NMSHandler.getInstance().getEntityHelper().getItemInHand(player);
    // which is probably the least intrusive
    if (item == null || item.getType() == Material.AIR) {
        item = new MaterialData(Material.STAINED_GLASS_PANE, DyeColor.GRAY.getDyeData()).toItemStack();
    } else {
        item = item.clone();
    }
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(message);
    item.setItemMeta(meta);
    int slot = player.getInventory().getHeldItemSlot() + 36;
    NMSHandler.getInstance().getPacketHelper().setSlot(player, slot, item, true);
    slotChanged.put(player.getUniqueId(), slot);
}
Also used : MaterialData(org.bukkit.material.MaterialData) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 10 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project Minigames by AddstarMC.

the class MenuItem method setItem.

public void setItem(ItemStack item) {
    if (item == null) {
        Bukkit.getLogger().fine("Item Stack was null on: " + this.getDescription().toString());
        return;
    }
    ItemMeta ometa = displayItem.getItemMeta();
    displayItem = item.clone();
    ItemMeta nmeta = displayItem.getItemMeta();
    nmeta.setDisplayName(ometa.getDisplayName());
    nmeta.setLore(nmeta.getLore());
    displayItem.setItemMeta(nmeta);
}
Also used : ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Aggregations

ItemMeta (org.bukkit.inventory.meta.ItemMeta)47 ItemStack (org.bukkit.inventory.ItemStack)17 ArrayList (java.util.ArrayList)5 Enchantment (org.bukkit.enchantments.Enchantment)5 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)4 BookMeta (org.bukkit.inventory.meta.BookMeta)3 FireworkEffectMeta (org.bukkit.inventory.meta.FireworkEffectMeta)3 SkullMeta (org.bukkit.inventory.meta.SkullMeta)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 StringTag (net.aufdemrand.denizen.nms.util.jnbt.StringTag)2 Element (net.aufdemrand.denizencore.objects.Element)2 FireworkEffect (org.bukkit.FireworkEffect)2 Material (org.bukkit.Material)2 Banner (org.bukkit.block.Banner)2 BannerMeta (org.bukkit.inventory.meta.BannerMeta)2 BlockStateMeta (org.bukkit.inventory.meta.BlockStateMeta)2 EnchantmentStorageMeta (org.bukkit.inventory.meta.EnchantmentStorageMeta)2 LeatherArmorMeta (org.bukkit.inventory.meta.LeatherArmorMeta)2 RewardType (au.com.mineauz.minigames.minigame.reward.RewardType)1