Rename items

Discussion in 'Plugin Development' started by Forseth11, Oct 28, 2013.

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

    Forseth11

    How would I create a method to rename ItemStacks like you see on large servers in the inventories.
    I tried setting display name and that does not work.
     
  2. Offline

    Shzylo

    you want to get the itemstack at hand first, get that metadata, set the display name and lore through the metadata, then set the itemstack's metadata to the new metadata:

    Code:java
    1. ItemStack i = new ItemStack(Material.STONE);
    2. ItemMeta meta = i.getItemMeta();
    3. ArrayList<String> lore = new ArrayList<String>();
    4. lore.add("This is lore");
    5. meta.setLore(lore);
    6. meta.setDisplayName("Not Stone");
    7. i.setItemMeta(meta)
     
  3. Make sure when you're done you execute setItemMeta(meta) on the ItemStack object.
     
    Shzylo likes this.
  4. Offline

    Forseth11

Thread Status:
Not open for further replies.

Share This Page