Sorry, didnt make my self clear, what im using as a "template" is actually the L2NpcTemplate itself, annotated, i do not clone the whole hierarchy, i just make a new instance and set the fields(using StatsSet on that pack) accordingly.
A noSQL system on a l2j server is a bad idea, mysql outperforms mongodb in some locations, its still a server and its just not worth it, if there was a an "embed" option of it, then yeah.
MongoDB is a documented database server. Imagine mysql saving tables as xmls. Tho those guys used json since its less chars and if u binary it(more like binary string serialization) with bson, it gives out a better import/export performance. But still, its outperformed as a server by mysql. NoSQL is good for game engines or applications that need to have a dedicated database for standalone use.
Still, it would be pretty neet if you could unserialize a template in case of an emergency, i know its possible with java implementations of bson, but not sure how that will be possible with mongodb, since they use json at its fullest even translating it to java script.
Anyway, json is pretty nifty, and there are alot of serialization implementations of it. Like Jackson @ codehouse. What i like of it is that, we can lazy cache stuff and we can manipulate strings how we want, when we want effectivly.
For instance:
A folder of data, if i was to make a jaxb implementation for the skill system, i would of have to get all xmls and then dom-parse them all then write all that data in a single xml cache, then i will have to call JAXB and start the unmarshal process. That means i will also have to make a "file aware of change system", and then re-cache all that data.
In an l2j server by the time it got to the half of the process i would get an "out of memory exception" :P
With json, i can just read the file, drop every white space while reading the stream, and then do w/e the hell i want XD I can even get data recursively, meaning i can specify:
boolean asArrayMap = true;
int depth = 1; // i did depth 1, it will only get me the first entrys, SkillName skillId and level.
JsonData = json_decode(new SomeReader..., asArrayMap, depth);
Doing so, i wont need to create a new Skill instance just to print the skill name and level, i then can serialize the data again in json or keep it in a map. Easy and memory efficient.
Also this si how a json based skill would look like:
{
"skill" :{
"name": "Deadly Blow",
"level": 3,
"powerLevels": [35, 33, 120],
"effects": {
"sleep": {
"time": 1000,
"effectIcon": "someIcon"
}
}
}
}
Paste it here for highlighting: http://json.parser.online.fr/
And there are a lot of uses, its like the discovery of petrol xD
EDIT: I forgot since its basically javascript, you can get it here highlighted right: http://pastebin.com/F7q7dcUL