Search in sources :

Example 1 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project TotalFreedomMod by TotalFreedom.

the class Command_cake method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    final StringBuilder output = new StringBuilder();
    final String[] words = CAKE_LYRICS.split(" ");
    for (final String word : words) {
        output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
    }
    final ItemStack heldItem = new ItemStack(Material.CAKE);
    final ItemMeta heldItemMeta = heldItem.getItemMeta();
    heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
    heldItem.setItemMeta(heldItemMeta);
    for (final Player player : server.getOnlinePlayers()) {
        final int firstEmpty = player.getInventory().firstEmpty();
        if (firstEmpty >= 0) {
            player.getInventory().setItem(firstEmpty, heldItem);
        }
        player.awardAchievement(Achievement.BAKE_CAKE);
    }
    FUtil.bcastMsg(output.toString());
    return true;
}
Also used : Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 2 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project GameCore by Warvale.

the class ClassSelect method openGUI.

private void openGUI(Player player) {
    inv = Bukkit.createInventory(null, 45, ChatColor.DARK_GRAY + "Select a class: ");
    Integer inventoryIndex = 0;
    for (Map.Entry<String, Class> clazzSet : ClassManager.classes.entrySet()) {
        Class clazz = clazzSet.getValue();
        ItemStack classStack = clazz.getItem();
        ItemMeta classMeta = classStack.getItemMeta();
        List<String> desc = new LinkedList<>(clazz.getDescription());
        desc.add(0, ChatColor.translateAlternateColorCodes('&', "&7PRICE: &e" + clazz.getPrice()));
        desc.add(1, ChatColor.GRAY + "ABILITY: " + ChatColor.YELLOW + clazz.getAbility());
        classMeta.setLore(desc);
        classMeta.setDisplayName(ChatColor.AQUA + clazz.getName());
        classStack.setItemMeta(classMeta);
        inv.setItem(inventoryIndex, classStack);
        slots.put(inventoryIndex, clazz);
        inventoryIndex = inventoryIndex + 1;
    }
    player.openInventory(inv);
}
Also used : Class(net.warvale.core.classes.Class) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 3 with ItemMeta

use of org.bukkit.inventory.meta.ItemMeta in project GameCore by Warvale.

the class TeamSelect method tsGUI.

private void tsGUI(Player player) {
    inv = Bukkit.createInventory(null, 9, ChatColor.DARK_GRAY + "Select a team:");
    Wool wool_red = new Wool(DyeColor.RED);
    ItemStack itemtsred = wool_red.toItemStack(1);
    ItemMeta itemtsredmeta = itemtsred.getItemMeta();
    itemtsredmeta.setDisplayName(ChatColor.RED + "Red");
    itemtsred.setItemMeta(itemtsredmeta);
    Wool wool_cyan = new Wool(DyeColor.CYAN);
    ItemStack itemtscyan = wool_cyan.toItemStack(1);
    ItemMeta itemtscyanmeta = itemtscyan.getItemMeta();
    itemtscyanmeta.setDisplayName(ChatColor.DARK_AQUA + "Blue");
    itemtscyan.setItemMeta(itemtscyanmeta);
    ItemStack closemenu = new ItemStack(Material.BARRIER, 1);
    ItemMeta closemenumeta = closemenu.getItemMeta();
    closemenumeta.setDisplayName(ChatColor.DARK_RED + "Close selector");
    closemenu.setItemMeta(closemenumeta);
    inv.setItem(3, itemtsred);
    inv.setItem(4, closemenu);
    inv.setItem(5, itemtscyan);
    player.openInventory(inv);
}
Also used : Wool(org.bukkit.material.Wool) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 4 with ItemMeta

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

the class ItemDisplayname method adjust.

@Override
public void adjust(Mechanism mechanism) {
    if (mechanism.matches("display_name")) {
        ItemMeta meta = item.getItemStack().getItemMeta();
        meta.setDisplayName(EscapeTags.unEscape(mechanism.getValue().asString()));
        item.getItemStack().setItemMeta(meta);
    }
}
Also used : ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 5 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)

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