ArrayList to check

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

ArrayList to check

Post by Bencratus »

Hello,

e.g. character have these buffs in arraylist which will be added if he press button x,a,b etc.

List <Integer> _buffs = new ArrayList<>();

_buffs.add(100);
_buffs.add(101);
_buffs.add(102);

how to check how much he have buffs which ids are 101 and 102?
because if _buffs.size(); it will returns all hes buffs count, but I need only e.g. 101 and 102.
also _buffs.contains don't need for me, because it is boolean, I need int...

Thanks,
Bencratus
User avatar
Zealar
L2j Veteran
L2j Veteran
Posts: 1236
Joined: Sun Jul 15, 2007 10:29 am

Re: ArrayList to check

Post by Zealar »

Replace list with map ;)
Sdw
L2j Veteran
L2j Veteran
Posts: 855
Joined: Mon May 03, 2010 8:38 am
Location: France

Re: ArrayList to check

Post by Sdw »

Difficult to know what you are really doing so I'm just going to give you what you wanted

long buffCount = _buffs.stream().filter(b -> (b == 101 || b == 102)).count();
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

Re: ArrayList to check

Post by Bencratus »

Zealar wrote:Replace list with map ;)
Thanks, helped :)
Sdw wrote:Difficult to know what you are really doing so I'm just going to give you what you wanted

long buffCount = _buffs.stream().filter(b -> (b == 101 || b == 102)).count();
Thanks, but your method for me hardcoded if I want to use more buffs not only these 2 ;)
Post Reply