get original lore and name from itemstack

Discussion in 'Plugin Development' started by Maximvdw, Feb 2, 2014.

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

    Maximvdw

    Hi there,
    I was thinking, is there a simple way to get the original name and lore from an itemstack?
    For the name I was thinking of creating a new ItemStack based on the getType() from the old one.
    Then copy the name to the old itemstack.

    But I don't really know a good way to restore the lore?

    Best Regards,
    Maximvdw
     
  2. Code:java
    1. ItemStack i1 = new ItemStack(Material.GRASS)
    2. ItemStack i2 = new ItemStack(Material.GRASS)
    3. ItemMeta itemstackMeta = i1.getItemMeta();
    4.  
    5. ArrayList<String> lore = new ArrayList<String>();
    6. lore.add("Lore");
    7. itemstackMeta.setLore(lore);
    8. i1.setItemMeta(itemstackMeta);


    Thats to set the lore, just for debugging now, then to set the lore of a new itemstack based on the old one:

    Code:java
    1. itemstackMeta2 = i2.getItemMeta();
    2. itemstackMeta2.setLore(itemstackMeta.getItemMeta.getLore();
    3. i2.setItemMeta(itemstackMeta2);
     
  3. Offline

    Maximvdw

    Thanks for your reply. However this is not exactly what I am looking for.

    I have an itemstack modified by 'A' plugin to get a custom text and lore. I want to revert it to the original lore and text (even when it has an enchantment on it)

    So the name is easy, because it is the same as the material name. But for the lore (with enchants) I don't know an easy way.
     
Thread Status:
Not open for further replies.

Share This Page