Sync with L2jServer HighFive Feb 18th 2015.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package com.l2jserver.gameserver.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Logger;
|
||||
@@ -38,7 +37,7 @@ import com.l2jserver.util.Rnd;
|
||||
*/
|
||||
public class MinionList
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(MinionList.class.getName());
|
||||
private static final Logger _log = Logger.getLogger(MinionList.class.getName());
|
||||
|
||||
protected final L2MonsterInstance _master;
|
||||
/** List containing the current spawned minions */
|
||||
@@ -85,7 +84,8 @@ public class MinionList
|
||||
return;
|
||||
}
|
||||
|
||||
int minionCount, minionId, minionsToSpawn;
|
||||
int minionCount, minionId;
|
||||
long minionsToSpawn;
|
||||
for (MinionHolder minion : minions)
|
||||
{
|
||||
minionCount = minion.getCount();
|
||||
@@ -272,22 +272,16 @@ public class MinionList
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// searching in reused minions
|
||||
if ((_reusedMinionReferences != null) && !_reusedMinionReferences.isEmpty())
|
||||
if (_reusedMinionReferences != null)
|
||||
{
|
||||
L2MonsterInstance minion;
|
||||
Iterator<L2MonsterInstance> iter = _reusedMinionReferences.iterator();
|
||||
while (iter.hasNext())
|
||||
final L2MonsterInstance minion = _reusedMinionReferences.stream().filter(m -> (m.getId() == minionId)).findFirst().orElse(null);
|
||||
if (minion != null)
|
||||
{
|
||||
minion = iter.next();
|
||||
if ((minion != null) && (minion.getId() == minionId))
|
||||
{
|
||||
iter.remove();
|
||||
minion.refreshID();
|
||||
initializeNpcInstance(_master, minion);
|
||||
return;
|
||||
}
|
||||
_reusedMinionReferences.remove(minion);
|
||||
minion.refreshID();
|
||||
initializeNpcInstance(_master, minion);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// not found in cache
|
||||
@@ -397,17 +391,9 @@ public class MinionList
|
||||
|
||||
// Statistics part
|
||||
|
||||
private final int countSpawnedMinionsById(int minionId)
|
||||
private final long countSpawnedMinionsById(int minionId)
|
||||
{
|
||||
int count = 0;
|
||||
for (L2MonsterInstance minion : _minionReferences)
|
||||
{
|
||||
if ((minion != null) && (minion.getId() == minionId))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return _minionReferences.stream().filter(npc -> npc.getId() == minionId).count();
|
||||
}
|
||||
|
||||
public final int countSpawnedMinions()
|
||||
@@ -417,6 +403,6 @@ public class MinionList
|
||||
|
||||
public final long lazyCountSpawnedMinionsGroups()
|
||||
{
|
||||
return _minionReferences.stream().distinct().count();
|
||||
return _minionReferences.stream().map(L2MonsterInstance::getId).distinct().count();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user