Jump to content
  • 0

help with map list & arraylist


tazerman2
 Share

Question

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);
						}

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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`
Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0
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`
Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Posts

    • Hello, if you order, always order with refill so you are 100% sure, the followers,likes stay.   We now accept PayPal sometimes, open ticket and ask, our support team will tell you if we accept it or not.
    • AM Acumen +3 DB Clean Drac Armor set  DC robe set AS Clean TT SET +3 1.5B Adena in stock  discord : AliTarash#5255 or dm here 
    • private int _ispro; private long _isproTime; public void increasePvpKills(L2Character target) {     if (target instanceof L2PcInstance && AntiFeedManager.getInstance().check(this, target))     {         if (_isproTime < System.currentTimeMillis())             _ispro = 0;           _ispro++;         _isproTime = System.currentTimeMillis() + 60000L;   There is no need for any task or anything..
    • Hi, i make 4 new custom zone where can set zonename, but have problem bcs  still working only last zonename for all new zones...   373    0    26    16    30000.00000000    -30000.00000000    a,TvT Event\0    -1    -1    -1    -1    -1    -1    0.00000000    a, 374    0    16    16    30000.00000000    -30000.00000000    a,TvT Event\0    -1    -1    -1    -1    -1    -1    0.00000000    a, 375    0    21    11    30000.00000000    -30000.00000000    a,TvT Event\0    -1    -1    -1    -1    -1    -1    0.00000000    a, 376    0    17    16    30000.00000000    -30000.00000000    a,PvP Zone\0    -1    -1    -1    -1    -1    -1    0.00000000    a,   Some1 understand it how its working ? i need set new nbr, zone_color_id and other geodata coords + 1 map for zone... If all working good ofc i pay for it 😉 pm on discord: ! KejbL#0290 thx.
    • LF BP MAIN  PM US AT DISCORD APO#2611 OR OUR FACEBOOK PAGE !
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock