Consists of 3 classes: Metadata, MetadataGroup, MetadataNode
I tried implementing a Metadata framework that allows plugins to add additional metadata to a Player.
This can be used by e.g Permission Managers to assign a "group", "prefix" or similar additional data to the player.
Another plugin can then get this metadata easily without depending on a specific Permission Manager.
If a unofficial unwritten agreement is that group names will be assigned to a Metadata named "group" every plugin can use this information.
Every plugin can assign a metadata key/value, when a plugin assigns the same key/value again the value is overwriting the old value, this a plugin can only assign 1 value to a key.
HOWEVER I've implemented that each plugin can assign a key/value pair with the same key, it will just be added to a internal list/hashmap.
When asking for the Metadata, a list of metadata will be returned (if only 1 value is present only 1 value will be in the list), if multiple plugins have added metadata to the same key, e.g. "group", then the list will contain all the "group" metadata assigned by the plugins.
Plugins can then decide whether to just use one of the value or generate a delimited joined string of the values. E.g multiple groups could be joined to form "Group1/Group2/Group3" if 3 different plugins have assigned 3 different groups.
More work on this is probably need as the nodes are contained in a HashMap and will be returned in no particular order (Hashed order). Something like a level/priority property or FIFO queue would probably be needed, TreeMap?.
A metadata assigned by a specific plugin can also be requested either by the Plugin instance or by plugin name.
I am only using groups as an example because many people can relate to this, but there are MANY more uses of this.
I was thinking whether it would be useful to move this "up the tree", so instead of just allowing metadata on Player, move it to HumanEntity or maybe even all the way up to Entity allow metadata on ALL entities. But I'd like to take this discussion first.
I am not sure my implementation is absolutely perfect, but I'm hoping for some response and a little discussion about this subject, hopefully this could catch on. It would probably also need access methods such as getString, getBoolean, getInt and the likes. Currently it is only implemented as getValue, which returns a object.
Setting a Metadata example:
player.setMetadata(plugin, "key", "value");
Getting Metadata examples (4 examples, so BukkitDev paste'd it):
http://dev.bukkit.org/paste/4153/
Forum thread discussing the matter about Permissions/Metadata:
http://forums.bukkit.org/threads/idea-design-a-better-permissions-plugin.42131/
Corresponding CraftBukkit Pull Request:
https://github.com/Bukkit/CraftBukkit/pull/517