using metadata

Discussion in 'Plugin Development' started by waflija, Mar 10, 2012.

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


    How can I create MetaData to use with "setMetadatavalue" ?
  2. Offline


    You can use this if in a event and getting metadata of a item:
    if (event.getItem().getDurability() == 51)
    Metadata is the same as durability. Therefore you can use setDurability.
  3. Offline


    Check the javadocs. (org.bukkit.metadata)

    You can use a FixedMetadataValue or a LazyMetadataValue. You could probably implement your own too, if you wanted to. Shouldn't be necessary though.
  4. Offline


  5. Offline


    I read through the docs, thanks, that gave me a lot of insight.

    Now, I am curious, what sort of persistence (if any) is in place or planned for metadata?

    The fact that they are linked to callables in a Lazy type makes me think this is more of a runtime-only value thing, but I'm just curious, especially given there is a Fixed version of the class.

    (Assuming this is runtime-only data,) let's hypothesize a theoretical protection plugin, it'd be very neat for the protection plugin to register on a Block e.g. a Metadatavalue of e.g. ("protected", FixedMetadataValue(true)) or ("protectedOwner", FixedMetadataValue("crast")). If there is no persistence, does that mean the protection plugin will have to find a place to load from its own persistence store (say, when a chunk is loaded for the first time)?

    Don't get me wrong, even with no persistence, this is still a hugely useful tool, due to the ability to have data-locality, useful data plugins want to attach for runtime use can be done directly onto a block or entity rather than a separate lookup in a HashMap. I'm thoroughly excited to get to using this.
  6. Offline


    Bukkit currently does not support metadata persistence - getting this first iteration included in Bukkit was enough of a challenge. :)

    Part of the vision for metadata was to provide a mechanism for mediating data exchange between plugins - just as the Bukkit permissions framework mediates permission exchange between permission providers (BPermissions, PEX, etc.) and the plugins that consume permissions. The parallel between permissions and metadata also extends to persistence. The API provides the exchange protocol but the provider plugins must provide their own persistence model as needed.
Thread Status:
Not open for further replies.

Share This Page