petteyg/OddItem — pull request #5 by chrisyco (2011-11-09 06:33:54+00:00)
Title: Miscellaneous refactoring

A few minor changes here and there, that should make the code a bit more manageable.

In ascending order of debatability:

* `getAliases` now throws an IllegalArgumentException with the best match, just like `getItemStack`.

* Refactored BKTree to separate the multiple distance thingies from the configuration code.

* Made `ItemGroup` immutable. There's not much point letting other plugins change the items in the group, since the changes never get saved anyway.

* Changed `getAliases` to return a NavigableSet instead of a List. This one I really don't know about—I have a feeling other plugins may break from this. However, I haven't seen any plugin other than mine use that method. Should I create a new method, maybe called `getAliasSet`?

* Created a new immutable class `ItemSpecifier`—pretty much, an ItemStack without the amount. It just didn't make sense using mutable values as map keys. Also, this makes the lookup code much cleaner. I remember you mentioned adding both x and x;0 to the map—this solves that problem very nicely.

Plus, some ideas I haven't done yet, but we should consider:

* Move all the inventory methods into a separate class called `Inventories` or `ItemStacks` to stop the main class from getting cluttered.

* Clean up the configuration code, and maybe port it to the new configuration API (I've heard it's really good)

Questions welcome. Enjoy :)