Right now there is a lot of hard-coded checks through out the code for handling specific objects (like items). Rather than having a bunch of if ... else if ... else's in the code, use more configuable ways of adding/changing implementation. The first step to this would have the implementation configurable during run-time. This would allow one to plugin an alterative implementation without changing core code (just thier java class and the config).
As a starting point for this, here is a patch file to allow item implementations to be defined via the items.xml file, and remove the hard-coded portions from DefaultItem.java.
If excepted, I can make more enhancements to make it faster. I haven't actually run them in a real server (I just ran a modified main in ItemxXMLLoader to create an instance of each, and it seemed to work fine).
As a side effect, the stackable xml attribute is probably obsolete, since the config chooses whether to use a regular Item or StackableItem via the java class. Right now there is still a legacy safety-net in DefaultItem to use the appropriete item/stackable item impl if a class isn't defined in the xml file.. ideally this would be removed after a while (giving time for anyone using the code to catch up and always specify an implementation).
Also, if excepted.. I plan to refactor Scroll into a set of sub-classes that do actual implementation (rather than the if/else if/else in the one class now). This would make it easier to add/change scrolls without (or minimal) effect on other code changes.
NOTE: This is the first time I'm adding an attachment to SF.. so lets see if all goes well. ;)
Oh.. and someone should veryify I got all the xml impls right. I filled in the specific classes/subclasses from DefaultItem and then did a lot of copy/pasting for the stackable/non-stackable.. so there's the potential for an error.
Anonymous
[diff] patch file for changes
Logged In: NO
Oh.. and everywhere I used "excepted" instead of "accepted".. well, you know what I meant! =)
(Been typing Exception too much I guess).
"Damnit Jim! I'm a programmer, not an english teacher".
Logged In: YES
user_id=990499
Originator: NO
Hi ChadF,
thanks for submitting this patch, it is commited to CVS now.
Hendrik