Instance use of LinkedList for unknown length lists.
This commit is contained in:
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.instancezone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -175,23 +176,6 @@ public class InstanceWorld
|
||||
return _instance.getNpcs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alive NPCs from instance.
|
||||
* @return set of NPCs from instance
|
||||
*/
|
||||
public List<Npc> getAliveNpcs()
|
||||
{
|
||||
final List<Npc> result = new ArrayList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if (npc.getCurrentHp() > 0)
|
||||
{
|
||||
result.add(npc);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get spawned NPCs from instance with specific IDs.
|
||||
* @param id IDs of NPCs which should be found
|
||||
@@ -199,7 +183,7 @@ public class InstanceWorld
|
||||
*/
|
||||
public List<Npc> getNpcs(int... id)
|
||||
{
|
||||
final List<Npc> result = new ArrayList<>();
|
||||
final List<Npc> result = new LinkedList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if (CommonUtil.contains(id, npc.getId()))
|
||||
@@ -221,7 +205,7 @@ public class InstanceWorld
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T extends Creature> List<T> getNpcs(Class<T> clazz, int... ids)
|
||||
{
|
||||
final List<T> result = new ArrayList<>();
|
||||
final List<T> result = new LinkedList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if (((ids.length == 0) || CommonUtil.contains(ids, npc.getId())) && clazz.isInstance(npc))
|
||||
@@ -232,6 +216,41 @@ public class InstanceWorld
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alive NPCs from instance.
|
||||
* @return set of NPCs from instance
|
||||
*/
|
||||
public List<Npc> getAliveNpcs()
|
||||
{
|
||||
final List<Npc> result = new LinkedList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if (npc.getCurrentHp() > 0)
|
||||
{
|
||||
result.add(npc);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alive NPCs from instance with specific IDs.
|
||||
* @param id IDs of NPCs which should be found
|
||||
* @return list of filtered NPCs from instance
|
||||
*/
|
||||
public List<Npc> getAliveNpcs(int... id)
|
||||
{
|
||||
final List<Npc> result = new LinkedList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId()))
|
||||
{
|
||||
result.add(npc);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get spawned and alive NPCs from instance with specific IDs and class type.
|
||||
* @param <T>
|
||||
@@ -243,7 +262,7 @@ public class InstanceWorld
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T extends Creature> List<T> getAliveNpcs(Class<T> clazz, int... ids)
|
||||
{
|
||||
final List<T> result = new ArrayList<>();
|
||||
final List<T> result = new LinkedList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if ((((ids.length == 0) || CommonUtil.contains(ids, npc.getId())) && (npc.getCurrentHp() > 0)) && clazz.isInstance(npc))
|
||||
@@ -254,24 +273,6 @@ public class InstanceWorld
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alive NPCs from instance with specific IDs.
|
||||
* @param id IDs of NPCs which should be found
|
||||
* @return list of filtered NPCs from instance
|
||||
*/
|
||||
public List<Npc> getAliveNpcs(int... id)
|
||||
{
|
||||
final List<Npc> result = new ArrayList<>();
|
||||
for (Npc npc : _instance.getNpcs())
|
||||
{
|
||||
if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId()))
|
||||
{
|
||||
result.add(npc);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first found spawned NPC with specific ID.
|
||||
* @param id ID of NPC to be found
|
||||
|
Reference in New Issue
Block a user