sk89q/commandbook — pull request #103 by NathanWolf (2014-05-07 00:18:01+00:00)
Title: Add API for Custom Kit Items

This PR adds a simple API so that other Plugins may register an ItemProvider, which the Kit object will now use (via ItemUtil) when creating new items for a kit.

Each registered ItemProvider will be queried, and if it provides for the requested key, it can return an ItemStack to be added to the kit.

A use example for the Magic plugin (which I used to test this integration) is putting "wand: guest" in the "starter" kit. If Magic is present, it will provide a wand in the kit when requested.

This PR also slightly changes the way Kits work internally, the more invasive of the two changes. A Kit will now store an item id/amount pair, rather than a pre-generated ItemStack. This was mainly needed because Kits load before dependent plugins get a chance to register, but it also has the bonus side-effect of supporting randomized or otherwise dynamic items (e.g. "wand: random(20)" in the Magic plugin will produce a randomly-generated level-20 wand)

I appreciate you looking this over and considering it as an addition to CommandBook. I've really been enjoying having this plugin on my server since moving away from Essentials, and being able to provide wands in kits is the last piece I'm missing from that cutover. I already integrate with CommandBook for warps in a teleport spell I have, which has been working really well, so this is a logical extension for me. I just can't do it without a little API help.

Side-note: My integration with Essentials is hugely hacky (I use reflection to swap out their internal ItemDB class), I'd love to do better with CommandBook. I think this is a nice, reusable, interface that other plugins may want to take advantage of - if you have any feedback or comments, I'd be more than happy to work with you on it.

Thank you!