Item Metadata Help

Discussion in 'Plugin Development' started by ThePixelPony, Jun 8, 2014.

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


    So I am wondering if there's any way to attach custom meta tags to items in players' inventories. These tags would have to persist over server reloads and restarts.

    I'm trying to make a custom items plugin. For example, the metadata tag 'damage' would indicate to my plugin how much damage the item deals.
  2. Offline


    There are two kinds of meta data for ItemStacks. Meta data you can set on an object that implements Metadatable which is not persistent and ItemMeta which lets you set specific meta data like enchantments, display name and lore. Speaking of lore, this is the only thing I can imagine to use for this kind of plugin if you want to use only native techniques.

    You can set your attributes as lore and parse the lore every time you need access to your custom attributes. This has two major downsides: You will break other plugins using lore (and the other way round) and your attributes are all visible to the players.

    Another possibility is to use a database with proper caching mechanism or yml configuration to save attributes. Although you would need to identify ItemStacks in some way. This would need ItemMeta again I think. Although you could use dislpay name for this.
  3. Offline


    AmShaegar ItemStacks don't implement Metadatable
    AmShaegar likes this.
  4. Offline


    Oh, damn. Then ignore my comment about Metadatable. :)
Thread Status:
Not open for further replies.

Share This Page