setItemMeta()

Discussion in 'Plugin Development' started by xWatermelon, Dec 22, 2012.

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

    xWatermelon

    Hi Bukkit coders,
    I am making a plugin where I want to set ItemMeta to determine the difference between items. So I would get an iron sword, set some ItemMetaData, and later on on code check if it had some metadata to determine if the player spawned it. How can I setItemMeta, and how can I check if an item has it later on in my code? Thanks!
     
  2. Offline

    ZeusAllMighty11

    I'd like this too! ^_^
     
    xWatermelon likes this.
  3. Offline

    Malikk

    With setItemMeta all you can change is the display name and lore.

    Unless checking the name or lore is sufficient (which will both appear in the tooltip), you'll have to use the dreaded ,unstable craftbukkit and nms stacks to write your own NBT tags.
     
  4. Offline

    william9518

    Code:
    public ItemStack setOwner(ItemStack item, String name) {
              ItemMeta meta = (ItemMeta) item.getItemMeta();
              meta.setDisplayName(name);
              item.setItemMeta(meta);
              return item;
    }
    and idk how to check if it has a meta.
    List of ItemMetas:
    BookMeta
    EnchantmentStorageMeta
    FireworkEffectMeta
    FireworkMeta
    ItemMeta
    LeatherArmorMeta
    MapMeta
    PotionMeta
    Repairable
    SkullMeta
    for more detail, visit jd.bukkit.org/apidocs
     
    PDKnight likes this.
  5. Offline

    xWatermelon

    Hmmm... ok. Is there any way to determine an item from another without having to set the display name/lore or using NBTTags?
     
  6. Offline

    chasechocolate

    I want to be able to do this also in one of my plugins... Hopefully it can be done without stupid NBTTags!
     
  7. Offline

    RealDope

    They just need to start using Id's for items as well as Entities.
    You can get Entities based on their ID, so why not items? :p
     
  8. Offline

    Malikk

    I had used enchantments in the past, but that's even messier and even unsafe enchantments still show up in the tooltip/glow

    Because that's super unnecessary, lol.

    The itemMeta api just needs to be better imo, that would open a lot of possibilites to a lot of people who don't wanna write their own tags, especially with the 'safeguard' business we have to deal with now.
     
    ZeusAllMighty11 likes this.
Thread Status:
Not open for further replies.

Share This Page