Help Wanted - Adding Items with Custom Meta Info to a Bukkit inventory

Discussion in 'Plugin Development' started by CaLxCyMru, Jun 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    CaLxCyMru

    Hello there, I was wondering how I can add a item/Items to a Bukkit Inventory with Custom Meta Data - by this I mean Name and description.

    Example -
    name: Broken Sword
    desc: Type: Weapon

    Please help,
    Thank in advance
    CaLx
     
  2. Offline

    BajanAmerican

  3. Offline

    Alex3543

    ItemStack stack = new ItemStack(Material.IRON_SWORD, 1);
    ItemMeta im = stack.getItemMeta();
    im.setDisplayName("Broken Sword");
    im.setLore(Arrays.asList("Type: Weapon"));
    stack.setItemMeta(im);

    player.getInventory().addItem(new ItemStack(stack));
     
    ice374 likes this.
  4. Offline

    mickedplay

    Alex3543
    And how do I add 2 lines of information?
    If I write
    Code:
    itemstackXYZ.setLore(Arrays.asList("10 seconds");
    itemstackXYZ.setLore(Arrays.asList("-6 EXP-Level");
    
    only the first line is shown.
     
  5. Offline

    allestbs

    use a comma at the first array list

    Like this:
    Code:java
    1. itemstackXYZ.setLore(Arrays.asList("10 seconds", "-6 EXP-Level");


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  6. Offline

    mickedplay

Thread Status:
Not open for further replies.

Share This Page