ItemMeta returning false

Discussion in 'Plugin Development' started by MissGaby, Apr 17, 2013.

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

    MissGaby

    Hey,
    I've been looking all over the forums, but couldn't find an answer to this. I'm trying to get a value from the lore, but so far without success. I'm using this piece of code which returns false when I check if it has an item meta. Any suggestions?
    Code:
    if(item != null) {
              if(item.hasItemMeta()) {
                if(item.getItemMeta().hasLore()) {
                    List<String> lore = item.getItemMeta().getLore();
                    String allLore = lore.toString().toLowerCase();
                    Matcher valueMatcher = this.damageRegex.matcher(allLore);
                     
                    if (valueMatcher.find()) {
                        System.out.println(Integer.valueOf(valueMatcher.group(1)).intValue());
                    }
                }
            }
    Thanks for helping!
     
  2. lore.toString() is not what you're aiming for, it does not put out the contents into one string. You have to manually loop through all the lines and match each individual one.
     
  3. Offline

    MissGaby

    Alright, that's my bad. But then why does item.hasItemMeta() return false? It has a lore and a display name. Any suggestions?
     
  4. hm... Could you show how you set the metadata?
     
Thread Status:
Not open for further replies.

Share This Page