Jump to content
  • 0

help with map list & arraylist


Question

Posted

hello i have make a restore buffer with map & arraylist

so i need make a more option like player can save that list with name + can make a new list like fighter/mage

i think for me this method is better from scheme buffer.

anyway. how to get a list and make a new list with name

	private Map<Integer, ArrayList<Integer>> _restore = new HashMap<>();

i call this from add buff

	private ArrayList<Integer> getOwnBuffs(final int objectId)
	{
		if (_restore.get(objectId) == null)
		{
			synchronized (_restore)
			{
				_restore.put(objectId, new ArrayList<Integer>());
			}
		}
		return _restore.get(objectId);
	}

restore list
ArrayList<Integer> bufs = getOwnBuffs(player.getObjectId());
				for (final Integer id : bufs)
				{
					player.broadcastPacket(new MagicSkillUse(this, player, id, SkillTable.getInstance().getMaxLevel(id), 500, 0));
					SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
				}
from here he add buffs and he check if skill is not same from skill list
						if (!getOwnBuffs(player.getObjectId()).contains(skillId))
						{
							getOwnBuffs(player.getObjectId()).add(skillId);
						}

 

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

I don't know if this is what you want:

 

public static class BuffInfo
	{
		int skillId;
		int skillLvl;
		
		public BuffInfo(int skillId, int skillLvl)
		{
			this.skillId = skillId;
			this.skillLvl = skillLvl;
		}
		
		public int getSkillId()
		{
			return skillId;
		}
		
		public int getSkillLevel()
		{
			return skillLvl;
		}
		
		public Skill getSkill()
		{
			return SkillData.getInstance().getSkill(skillId, skillLvl);
		}
	}
	
	public Map<String, List<BuffInfo>> _buff = new HashMap<>();
	
	public Collection<BuffInfo> getBuffOfScheme(String scheme)
	{
		return _buff.get(scheme);
	}
	
	public void addBuffToScheme(String scheme, BuffInfo buff)
	{
		if (!_buff.containsKey(scheme))
		{
			_buff.put(scheme, new ArrayList<>());
		}
		_buff.get(scheme).add(buff);
	}
	
	public void applyScheme(L2PcInstance player, String scheme)
	{
		getBuffOfScheme(scheme).forEach(b -> b.getSkill().applyEffects(player, player));
	}

 

Note i gave you all possible methods, to store, save, retreive buffs. 

 

Also synchronized (_restore) ? Why since is not accessible from other.

Edited by Kara`
  • 0
Posted (edited)
48 minutes ago, Tryskell said:

You can literally inspire yourself from my scheme buffer and pick the codes part you want.

 

Kara the following method creates an empty list for nothing.


getBuffOfScheme

Oke, i changed it.

Edited by Kara`
  • 0
Posted (edited)

tnx kara & tryskell for help i try to make a list restore buff without use name and if any player need make a second list the only need to do is to use a name to old list for save buff like "fighter" and after make a new list like "mage"

Edited by tazerman2
  • 0
Posted
8 minutes ago, tazerman2 said:

tnx kata & tryskell for help i try to make a list restore buff without use name and if any player need make a second list the only need to do is to use a name to old list for save buff like "fighter" and after make a new list like "mage"

kata? Bitch plz.

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

    • Its always the people who build nothing that have the most to say!  15+ years of development experience with 10+ programming languages and countless completed projects. If your best argument is 'you discovered AI,' I'll assume you couldnt find anything wrong with the launcher.
    • Looks like somebody discovered AI recently
    • Added: Server monitoring has been added to the protection dashboard, available for Premium+ plans. Each entry displays: Account — game login. HWID — hardware ID. GSID — the game server the entry belongs to. IP — the player's address. Country — determined by IP, with flag and name. Useful for SEO promotion, do you know where more players come from Status — "Banned" or "OK". Extra windows — how many additional windows are allowed for this HWID beyond the global limit. Last seen — time of last activity.   At the top — a summary: total entries, number banned, time of the last report, and an Online/Offline indicator (based on how fresh the data from the protection is).   Filters and search Search by account, HWID, or IP. Country — select from countries actually present in the data. Game server (GS) — filter by GSID. Period — by last activity date (from / to). Banned only — quick filter for violators. Grouping — collapse data by HWID, IP, or account: one row per key with counts of accounts/HWIDs/IPs and number of entries. Handy for catching multi-accounters (many accounts from one HWID) and suspicious IPs.   Ban / Unban — banning by HWID blocks all accounts on that hardware. The protection will pick up the command within a minute; until applied, a "Pending…" status is shown. Grant windows — set additional windows (+N) for a specific HWID via a convenient selector. Single token per account to link the protection with the dashboard: Generate / Reissue token in one click. Show token — view the current value at any time. The token is stored encrypted. Don't share it with anyone — if compromised, simply reissue it and the old one stops working immediately. In the protection config, you can enable monitoring, insert the token, and change how often data is sent to the protection dashboard.
  • 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..