Solved setLore and getLore?

Discussion in 'Plugin Development' started by Qaez, Dec 4, 2013.

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

    Qaez

    Hello,

    I am making a Wand Plugin, and now I am working on spells but this isnt working..
    I want to set the lore of the wand to the current spell and then when the player left clicks it checks if the wand has the lore of a spell and then it needs to cast that spell. But this isnt working..

    I can really use some help on this:eek:
     
  2. Offline

    Chinwe

    What have you tried?
    itemMeta.setLore(lore) takes a List (each element is a different line), so if you wanted to have a single lined description, you could simply do itemMeta.setLore(Arrays.asList("Spell Name"));

    To check it:
    Code:
    if (item.hasItemMeta()) // checking it has meta
    {
      ItemMeta meta = item.getItemMeta();
      if (meta.hasLore()) // checking it has lore
      {
          String lore = meta.getLore().get(0); // gets the first item/top line
          ...
      }
    }
     
  3. Offline

    Qaez

    Chinwe It gives me an error on this line:
    String lore = meta.getLore().get(0);
     
  4. Offline

    Chinwe

    Qaez What error?
     
  5. Offline

    Qaez

  6. Offline

    Qaez

    This is solved!
    Make sure you set the ItemMeta for an ItemStack after changing lore!
    This is where I failed!
     
Thread Status:
Not open for further replies.

Share This Page