Jump to content

Recommended Posts

Posted (edited)

Alright as title says. Let's say we got an xml and we want to store objects which is a range of type. 

int[], ArrayLists, Strings e.t.c

 

Known ways:

 

1. Create ex. FastMap into FastMaps such as  FastMap<Integer, FastMap<String, int[]>>

which is complicated to put and retrieve objects.

 

2. Stats sets that contain other stats sets. We can add one statset into another and make a tree

 

Is there any other way and more efficient in order load items from xmls and  store them?

 

Ps. i would prefer an experienced person with java structure to answer and give other solutions that really make it easier and more dynamic.

Thanks

Edited by AccessDenied
Posted (edited)

A StatSet is nothing more than a extended HashMap with more methods, allowing you for a String key to retrieve any type of object. It allows easy fill on loading, for the cost of overhead. A StatSet shouldn't really be used because of the overhead generated by String key. You could for example move every single variable from L2PcInstance into a single StatsSet (which will allow you to drop every single getter and setter). Will you do it, knowing that you must .get( the Map when you could simply retrieve the correct boolean/int/String by yourself with a getter if that was written normally ? I don't think so.

 

Also, a FastMap got no use at all to load static data, you both don't need the potential concurrency from .shared(true), nor the ordered system. You just create overhead for nothing using a FastMap.

 

The proper way is to create you own class defining the object similar to... Everything else :P. For example, Castle is an object, filled by database on startup. On aCis I recently moved hardcoded or SQL data related to static stuff to XML, but basically the Castle object is filled with int, List<MercenaryTicket>, List<Integer>, etc etc...

 

So long answer short, create your own Object class holding properties, then either use a StatsSet to feed that object or put every single parameters in the constructor :

public class Castle
{
     int _castleId;
     String _name;

     // By feeding each parameters into constructor
     public Castle(int id, String name)
     {
          _castleId = id;
          _name = name;
     }


     // By feeding using a StatsSet
     public Castle(StatsSet data)
     {
          _castleId = data.getInteger("castleId");
          _name = data.getString("name");
     }
}

Obviously StatsSet is just more readable when you got 10, 15, 20 parameters to pass on the godamn constructor.

 

You can also feed your object using public setter. As you can see, the castle exemple simply got 2 properties when it normally got billions other (artifact id, circlet, list of mercenary tickets,...). The XML handles that scenario when parsing the XML :

...
if ("artifact".equalsIgnoreCase(cat.getNodeName()))
	castle.setArtifacts(cat.getAttributes().getNamedItem("val").getNodeValue());
...

And then, on Castle object :

public void setArtifacts(String idsToSplit)
{
	for (String idToSplit : idsToSplit.split(";"))
		_artifacts.add(Integer.parseInt(idToSplit));
}

That scenario is right for anything :

- ArmorSetTable uses ArmorSet as storage object.

- FishTable uses FishData

- CastleManager uses Castle

etc etc.

 

On aCis and latest L2J, you also have generic holders such as IntIntHolder which avoid to generate your own class but simply retrieve it from a id/value. IntIntHolder is useful to store skillId, skillLevel or itemId, price. Beware, IntIntHolder is still an object to create - it simply avoids you to write your own little inner classes when you need only to store a paired int/int.

Edited by Tryskell
Posted

A StatSet is nothing more than a extended HashMap with more methods, allowing you for a String key to retrieve any type of object. It allows easy fill on loading, for the cost of overhead. A StatSet shouldn't really be used because of the overhead generated by String key. You could for example move every single variable from L2PcInstance into a single StatsSet (which will allow you to drop every single getter and setter). Will you do it, knowing that you must .get( the Map when you could simply retrieve the correct boolean/int/String by yourself with a getter if that was written normally ? I don't think so.

 

Also, a FastMap got no use at all to load static data, you both don't need the potential concurrency from .shared(true), nor the ordered system. You just create overhead for nothing using a FastMap.

 

The proper way is to create you own class defining the object similar to... Everything else :P. For example, Castle is an object, filled by database on startup. On aCis I recently moved hardcoded or SQL data related to static stuff to XML, but basically the Castle object is filled with int, List<MercenaryTicket>, List<Integer>, etc etc...

 

So long answer short, create your own Object class holding properties, then either use a StatsSet to feed that object or put every single parameters in the constructor :

public class Castle
{
     int _castleId;
     String _name;

     // By feeding each parameters into constructor
     public Castle(int id, String name)
     {
          _castleId = id;
          _name = name;
     }


     // By feeding using a StatsSet
     public Castle(StatsSet data)
     {
          _castleId = data.getInteger("castleId");
          _name = data.getString("name");
     }
}

Obviously StatsSet is just more readable when you got 10, 15, 20 parameters to pass on the godamn constructor.

 

You can also feed your object using public setter. As you can see, the castle exemple simply got 2 properties when it normally got billions other (artifact id, circlet, list of mercenary tickets,...). The XML handles that scenario when parsing the XML :

...
if ("artifact".equalsIgnoreCase(cat.getNodeName()))
	castle.setArtifacts(cat.getAttributes().getNamedItem("val").getNodeValue());
...

And then, on Castle object :

public void setArtifacts(String idsToSplit)
{
	for (String idToSplit : idsToSplit.split(";"))
		_artifacts.add(Integer.parseInt(idToSplit));
}

That scenario is right for anything :

- ArmorSetTable uses ArmorSet as storage object.

- FishTable uses FishData

- CastleManager uses Castle

etc etc.

 

On aCis and latest L2J, you also have generic holders such as IntIntHolder which avoid to generate your own class but simply retrieve it from a id/value. IntIntHolder is useful to store skillId, skillLevel or itemId, price. Beware, IntIntHolder is still an object to create - it simply avoids you to write your own little inner classes when you need only to store a paired int/int.

 

 

First of all thanks for being serious. Afcourse Sset is more readable by user when you play with 10 different objects and variables example to store an Event Data which require let's say

1. team color (FastMap)

2. team name (FastMap)

3. map data which contain team position (FastMap into FastMap)

 

e.t.c and i don't know how many more variables can you store but since i made an event and i'm using FastMaps to store objects after 4 fastMaps it kinda start getting ridiculously hard. I mean only the idea

get(x).get(x).get(x).get(x) after 5 times it kill my brain.

 

Also i'm not really familiar when it come in Statset to load from xml. Everytime you load data from xml you have plenty of options and if they exist since you're using

 

 

 

if ("artifact".equalsIgnoreCase(cat.getNodeName()))

 

so since we don't know how many variables are loaded we can't set the statset. Maybe is complicated in my head thats why i asked any alternative idea. I want avoid making different classes

to make objects, i want keep all in 1 class and all in 1 method and make a simple style like    xxxx.getEvent(1).getData().getEventMap(1).getPositionForTeam(1); or something simple like that to avoid the 

mess i have right now with different classes. The idea behind this is to make a statsset that as you said extends HMs and contain other elements or other statsets inside if i'm right. The idea is pretty much easy.

I don't really want an example or anything i just wanted to know if the way i mention is better to be done with Sset or any other way in order to avoid making different classes and keep all in 1. 

 

Thanks again.

Posted

Are you trolling again or what? :lol:

No i'm actualy asking advice of someone more experienced to tell me if is ok to continue the idea i mentionted with the Sset or what. 

No searching for solution or examples just a yes or no and if is fine.

Posted

I answered you, StatsSet generates a overhead where basic properties don't. StatsSet should be kept only for data feeding.

 

And you obviously know what data you are loading for a raw stuff like Event. If you got a followup of get.get.get, it simply shows how terrible you structured your stuff. That's the sort of stuff to think BEFORE coding it.

 

An Event class probably has :

- int _id

- String _description

- List<L2PcInstance> _players

- List<Location> (or SpawnLocation) _spawnPoints

 

A Team class (can be edited for an extended enum) is different than a Event class. Don't melt everything. It probably has :

- int _id

- String _name

- int _color

 

etc etc.

Posted

It really depends what you want to do.

What should be taken into consideration:

- If object will change in time or loaded just once

- If it will be changed from multiple threads at the time

- How long(size, length) is it going to be

- What kind of access to it you want to have. It will be just fully iterated often, get(x), maybe you just want to take first index and then remove it?

 

Don't use FastList just because it is "fast".

 

If you want to load data from xml, i strongly suggest simple array(or obviously arrayList which might be later .trimToSize()).

 

Don't make FastMap<Integer, FastMap<String, int[]>>

Make:

ArrayList<MyContainer>();

class MyContainer
{
    private final int id;
    private final List<MySecondContainer> importantNameHere;
}

class MySecondContainer
{
    private final int String nameMaybe;
    private final int[] someKindOfData;
}

Thats most secure way.

- How long(size, length) is it going to be

Posted (edited)

It really depends what you want to do.

What should be taken into consideration:

- If object will change in time or loaded just once

- If it will be changed from multiple threads at the time

- How long(size, length) is it going to be

- What kind of access to it you want to have. It will be just fully iterated often, get(x), maybe you just want to take first index and then remove it?

 

Don't use FastList just because it is "fast".

 

If you want to load data from xml, i strongly suggest simple array(or obviously arrayList which might be later .trimToSize()).

 

Don't make FastMap<Integer, FastMap<String, int[]>>

Make:

ArrayList<MyContainer>();

class MyContainer
{
    private final int id;
    private final List<MySecondContainer> importantNameHere;
}

class MySecondContainer
{
    private final int String nameMaybe;
    private final int[] someKindOfData;
}

Thats most secure way.

- How long(size, length) is it going to be

 

Yeap kinda trying to make it like this

private final FastMap<Integer, ArrayList> _mapLocation = new FastMap<Integer, ArrayList>().shared();
	
	private class MapData
	{
		private String _mapName;
		private FastMap<Integer, ArrayList> mapLocation;
		
		private MapData(String mapName, FastMap<Integer, ArrayList> list)
		{
			_mapName = mapName;
			mapLocation = list;
		}
		
		public ArrayList getMapLocationByOwner(String owner)
		{
			ArrayList list = _mapLocation.get(owner);
			return list;
		}
		
		public String getMapName()
		{
			return _mapName;
		}
	}
	
	/**
	 * 
	 * @param id
	 * @return Selected map base on input id
	 */
	public MapData getMapById(int id)
	{
		if (_mapData.containsKey(id))
			return _mapData.get(id);
		else
			System.out.print("Error trying get null MAP");
		
		return null;
	}

Thats why i did until now but still is a bit fucked up..

 

And in ArrayList imma put HashMaps tho. Ps ignore the "_mapLocation.get(owner);"

Edited by AccessDenied
Posted

First of all, those locations are going to be just loaded and stay the same until server or xml restart yes? Then you dont need to make them .shared().

If you dont need shared, why bother to use FastMap at all, it is better to use HashMap.

 

Since you are querying the data by just .get(ID), map will be faster than list or set or other collections. 

You should notice that Map<Integer, something> creates Integer object for each record. Integer is not the same as int, it takes far more memory. If you have small collection, thats fine, why would we care. If you have big collection like all items, thats big deal.

Also in getMapById(int) int is cast to Integer, it takes additional time, but thats fine. You might use .getOrDefault in there, takes just 1 line.

 

ArrayList thing in MapData i skip.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Very nice and passionate effort. Good luck.
    • SX.ORG is a global proxy platform offering residential, mobile and datacenter IPs for SEO, web scraping, ad verification and multi-account management. It provides flexible IP rotation, precise geo-targeting, HTTP(S)/SOCKS5 support, API access and pay-as-you-go pricing based only on the traffic you use.
    • L2-IMBA — SEASON 2  Custom PvP / PvE Interlude · Every Class Playable BETA — LIVE NOW GRAND START — 11 September 2026, 20:00 GMT+2 https://l2-imba.com · https://discord.com/invite/jmhVpj8ySv ═══════════════════════════════════════ RATES & CORE SETTINGS ═══════════════════════════════════════ Chronicle — Interlude XP / SP — x45, level-adjusted curve Adena — x1 Max level — 90 Subclass — 1, to level 80 Starting hub — Giran Skills — Auto-learn, post-80 via custom trainers Loot — Auto-loot with low-value filtering Buffs — Extended duration, expanded slots, saved schemes Client limit — NO DUAL-BOXING, one client per player Automation — Built-in auto-farm with daily time limit Offline — Trading and crafting enabled Current beta configuration. Final values confirmed at launch sign-off. ═══════════════════════════════════════ All 31 third classes are developed to level 90 through five specialized trainers — there are no dead classes here. Tanks, daggers, archers, warriors, summoners, healers, buffers and crafters all have real post-80 progression and a role worth playing. Full PvE progression through ten farm zones, thirty-five themed encounters and eighteen tracked raids, feeding into gear-equalized Team vs Team and open-world PvP. This isn't a stat patch with a new name. L2-IMBA keeps the combat, classes and world of Interlude and builds a new endgame on top of it — new equipment branches, custom class development past level 80, purpose-built farm ecosystems, boss progression, crafting, and augmentation, all connected into one progression loop. Level and develop your class → choose an armor identity → clear themed farm content → collect materials and boss resources → craft and upgrade without abandoning your build → compete in equalized and open-world PvP → reach God's equipment. ═══════════════════════════════════════ ROLE MASTERY ARMOR ═══════════════════════════════════════ Starting at Dynasty, armor becomes a real build choice instead of a mandatory set everyone wears. Each armor type offers three role masteries plus a flexible Universal path — twelve paths per tier, sixty full-set configurations across the progression. The chest piece selects your mastery; a matching five-piece set activates it. HEAVY   Juggernaut — frontline wall, shield synergy, reflection   Spellbreaker — anti-magic fortress, spell disruption   Slayer — heavy armor turned offensive, vampiric sustain LIGHT   Bowmaster — ranged pressure, kiting, accuracy   Assassin — positional burst, blow reliability, dagger lethals   Berserker — high-risk carry, power rises as HP falls ROBE   Arcanist — rapid-fire critical casting   Invoker — high-impact nuking and debuffs   Oracle — dedicated healing and support Upgrade recipes preserve your chosen path through every tier: Dynasty → Zariche → Valakas → Cursed → God's The system is gear-driven, not class-locked. Build creatively. ═══════════════════════════════════════ LEVEL 90 CLASS DEVELOPMENT ═══════════════════════════════════════ Max level extended to 90. Five specialized trainers — Archer, Tank, Rogue, Warrior, Mystic — cover all 31 third classes in post-80 progression, with 470+ learning entries. Every race gets a custom passive from level one. Tanks get distinct Human/Elf/Dark Elf identities. Duelist gains a two-handed greatsword path. Fortune Seeker becomes a real fighter without losing its spoil identity. Maestro gets a durable frontline route. Summoners, cubics and servitors get deeper combat logic rather than stat scaling. This is backed by server-side combat work — dedicated handling for debuff proficiency, PvE skill damage, blows, lethals, bow reuse, vampirism and reflection. ═══════════════════════════════════════ THE FARMING WORLD ═══════════════════════════════════════ Ten dedicated farm destinations via Global Gatekeeper: Farm Coins 1 & 2, Holy, Fire/Water, Wind, Earth, Unholy, Golden, Chaotic and Night zones. Seven themed enemy families — Undead, Demon, Angel, Beast, Bug, Water, Fire — each with four stages and a mini-boss. Thirty-five distinct encounters, each with its own resource identity feeding crafting. Eighteen tracked raids — twelve Farm Raid Bosses and six Custom Epic Raid Bosses. Plus a scheduled group-based Party Zone with dynamically managed normal and rare spawns. ═══════════════════════════════════════ CRAFTING & ENDGAME ═══════════════════════════════════════ SOUL FORGE — recycle old weapons into tier resources, convert boss and farm materials, craft Legendary components. Old gear becomes input, not warehouse clutter. CURATED AUGMENTATION — data-driven Top-Grade and Legendary profiles with meaningful stat, active and passive pools. Active effects are categorized so the same effect can't be stacked through equipment swapping. EXTENDED ENCHANT — Custom Crystal and Legendary stages. On the Legendary route, a failed enchant does not destroy the item or reduce its enchant level. Long-term progression, not an all-or-nothing gamble. TREASURE CHESTS — Rare, Immortal, Epic and Legendary tiers feeding gear growth, crafting and augmentation. ═══════════════════════════════════════ PvP ═══════════════════════════════════════ Gear-equalized Team vs Team on a recurring schedule — your equipment is snapshotted and restored, so the fight is about play, not who farmed longest. Open-world PvP with rewards and ranks alongside it. ═══════════════════════════════════════ QUALITY OF LIFE ═══════════════════════════════════════ - No dual-boxing — one client per player, enforced - Built-in auto-farm with a daily time limit — no third-party software needed, and third-party automation is bannable - Auto-learn skills, auto-loot with low-value drop filtering - Extended-duration buffs, expanded slots, saved schemes - Offline trading and crafting - Global Gatekeeper, global class change - Offline combat automation disabled ═══════════════════════════════════════ BY THE NUMBERS ═══════════════════════════════════════ 380+ custom item definitions · 110+ weapons and shields · 210+ armor and wearables · 250+ custom skill definitions · 2,700+ custom monster placements · 90+ shop and exchange catalogs · 1,100+ offers ═══════════════════════════════════════ BETA ═══════════════════════════════════════ Core systems, progression identities and content routes are in place. Exact item bonuses, mastery values, skill strength, reuse times, augment pools, enchant chances, drop rates and crafting costs remain subject to testing. Beta changes will refine balance without removing the defining role of each mastery or the overall progression structure. All beta characters are wiped at full launch. Beta testers keep their rewards. ═══════════════════════════════════════ OPEN BETA — 4 SEPTEMBER 2026 · 18:00 GMT+2 Website: https://l2-imba.com Wiki: https://l2-imba.com/wiki Register: https://l2-imba.com/account Download: https://l2-imba.com/start-playing Discord:  https://discord.com/invite/jmhVpj8ySv
    • 🛡️ 100% Safe on your personal Gmail. Zero VPN required and works globally. Grab yours directly on klouditem.com!
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..