oDrop XMLGEN (generates item-related structure class etc.)

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Hyrelius
Posts: 257
Joined: Thu Dec 16, 2010 5:16 am

oDrop XMLGEN (generates item-related structure class etc.)

Post by Hyrelius »

Hi there,
I'm working on some item management system and during this I had come across a lot of trouble.
While analyzing the structure of recipes was easy (due to the awesome XSD - big thanks!), analyzing skills was tougher. But it was the most difficult to analyze item-related XMLs (since my application is supposed to read all skills, items and recipes XML files to be able to query data from it).
oDrop XMLGen can do the following:
- create a XML file with item-related additional information (additionalItemInformation.xml), which contains data read from client data files
- create ItemDTO, ArmorItemDTO, WeaponItemDTO and EtcItemDTO classes with every attribute those have throughout all the XML-files (ItemDTO contains the attributes that are common to Armor, Weapon and EtcItem)
- find a certain attribute and/or its value within the item-related XML-files
If you want to know what Armor had the attribute "soulshots", you could find it using:
'java -jar xmlgen.jar -g:"X:\ITEMSFOLDER" -i -attr:soulshots -type:Armor'
Btw. I think it's an accident that a Dark Crystal Helmet - Heavy Armor has this attribute...
Or if you would like to find a weapon which has a particular item-skill, you'd write something like this:
'java -jar xmlgen.jar -g:"X:\ITEMSFOLDER" -i -attr:item-skill -attrVal:3559-2 -type:Armor'
I didn't really document the tool much since I didn't think of publishing it. However: I found it very useful when working with item-XMLs and maybe you find it useful as well. I'll publish the source code as soon as I've polished it a little.
It makes use of JDOM for dealing with XML files.
For generating that additional information, make sure the decrypted txt files are in the folder you specify.
'java -jar xmlgen.jar -g:"X:\FOLDER" -t:"F:\temp\additionalItemInformation.xml"'
FOLDER has to have certain item-related files that you normally have in your client.
This additional information will be used by my application in order to show various descriptions and other stuff that is not present in the server item-related XML-files.
Anyway. I hope you'll find this tool useful. If you have questions, feel free to post them here.
Cheers!
EDIT: I added some java-docs and comments here and there and now the source code is available as well. Feel free to modify it as you see fit. I'd be happy to see the changes though if you make any.
You do not have the required permissions to view the files attached to this post.
Last edited by Hyrelius on Mon Nov 21, 2011 9:24 am, edited 3 times in total.
Image
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
Hyrelius
Posts: 257
Joined: Thu Dec 16, 2010 5:16 am

Re: oDrop XMLGEN (generates item-related structure class etc

Post by Hyrelius »

Hi there,

I've figured out that there are still lots of things that are strange if you deal with item-related XMLs.

Some weapons and armors are defined as EtcItem for whatever reason (I suspect it's NCZ0ft's fault). Therefore I changed my XMLGEN-tool to write down the full element-list next to the attribute name in the comments.

For example the tool will generate the following:
private String weight; // example value: 30, full-attrName: set/weight
private String maxMp; // example value: 48, full-attrName: for/add/maxMp

Note: the type is always set to String, because there's no way (at least without too much hassle) to figure out the nearest matching type for the value provided. That's why it's up to you to replace them with the right type. You don't have to do this, of course, but I'd recommend to do so.

This way you'll be able to determine whether the attribute comes from a <set>-element directly under the <item>-element or if it comes from an attribute in the <cond>-, <and>- or <for>-element.

Then you can decide for yourself how you want to deal with it - I for instance created an ArrayList of ItemPlayerElementDTOs and ItemForElementDTOs that keep all those extra elements for each item. Also you should see if you really need that many attributes in the EtcItem class. My program is determining the true baseType (Weapon, Armor or EtcItem) by searching for "weapon_type", "armor_type" or "etcitem_type". However: there are also cases where none are set. Then you can't do anything but rely on the type you get from the <item>-element.

I've also an update for my tool. Now you can search for attributes within a certain type even if you don't know the value - like this:
java -jar xmlgen.jar -g:"X:\FOLDERTOITEMXMLS" -i -attr:attribute_name -attrValue:? -type:Weapon
You can also search for a value without knowing the attribute_name. Simply replace "attribute_name" with * and set the (exact) attribute-value. The aim is to see if any item within a certain type has a certain value at any attribute.

If you have any questions, feel free to ask. I'm also including the updated source files. As always: feel free to modify them any way you want. If you do so, I'd love to see the changes as they might help me as well :).

Enjoy!

P.s.: if anyone is interested I can provide you with the fully set *ItemDTO-classes, including all hand-made enumerations such as one for "materials", another one for "default_action" etc.
You do not have the required permissions to view the files attached to this post.
Image
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
Post Reply