|
@@ -31,6 +31,7 @@ import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Level;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.w3c.dom.NamedNodeMap;
|
|
import org.w3c.dom.NamedNodeMap;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.Node;
|
|
@@ -50,6 +51,7 @@ import com.l2jserver.gameserver.model.drops.IDropItem;
|
|
import com.l2jserver.gameserver.model.effects.L2EffectType;
|
|
import com.l2jserver.gameserver.model.effects.L2EffectType;
|
|
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
|
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
|
import com.l2jserver.gameserver.model.skills.Skill;
|
|
import com.l2jserver.gameserver.model.skills.Skill;
|
|
|
|
+import com.l2jserver.gameserver.util.Util;
|
|
|
|
|
|
/**
|
|
/**
|
|
* NPC data parser.
|
|
* NPC data parser.
|
|
@@ -717,18 +719,11 @@ public class NpcData extends DocumentParser
|
|
*/
|
|
*/
|
|
public List<L2NpcTemplate> getAllOfLevel(int... lvls)
|
|
public List<L2NpcTemplate> getAllOfLevel(int... lvls)
|
|
{
|
|
{
|
|
- final List<L2NpcTemplate> list = new ArrayList<>();
|
|
|
|
- for (int lvl : lvls)
|
|
|
|
- {
|
|
|
|
- for (L2NpcTemplate t : _npcs.values())
|
|
|
|
- {
|
|
|
|
- if (t.getLevel() == lvl)
|
|
|
|
- {
|
|
|
|
- list.add(t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
|
|
+ //@formatter:off
|
|
|
|
+ return _npcs.values().stream()
|
|
|
|
+ .filter(template -> Util.contains(lvls, template.getLevel()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //@formatter:on
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -738,18 +733,12 @@ public class NpcData extends DocumentParser
|
|
*/
|
|
*/
|
|
public List<L2NpcTemplate> getAllMonstersOfLevel(int... lvls)
|
|
public List<L2NpcTemplate> getAllMonstersOfLevel(int... lvls)
|
|
{
|
|
{
|
|
- final List<L2NpcTemplate> list = new ArrayList<>();
|
|
|
|
- for (int lvl : lvls)
|
|
|
|
- {
|
|
|
|
- for (L2NpcTemplate t : _npcs.values())
|
|
|
|
- {
|
|
|
|
- if ((t.getLevel() == lvl) && t.isType("L2Monster"))
|
|
|
|
- {
|
|
|
|
- list.add(t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
|
|
+ //@formatter:off
|
|
|
|
+ return _npcs.values().stream()
|
|
|
|
+ .filter(template -> Util.contains(lvls, template.getLevel()))
|
|
|
|
+ .filter(template -> template.isType("L2Monster"))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //@formatter:on
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -759,18 +748,12 @@ public class NpcData extends DocumentParser
|
|
*/
|
|
*/
|
|
public List<L2NpcTemplate> getAllNpcStartingWith(String... letters)
|
|
public List<L2NpcTemplate> getAllNpcStartingWith(String... letters)
|
|
{
|
|
{
|
|
- final List<L2NpcTemplate> list = new ArrayList<>();
|
|
|
|
- for (String letter : letters)
|
|
|
|
- {
|
|
|
|
- for (L2NpcTemplate t : _npcs.values())
|
|
|
|
- {
|
|
|
|
- if (t.getName().startsWith(letter) && t.isType("L2Npc"))
|
|
|
|
- {
|
|
|
|
- list.add(t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
|
|
+ //@formatter:off
|
|
|
|
+ return _npcs.values().stream()
|
|
|
|
+ .filter(template -> Util.startsWith(letters, template.getName()))
|
|
|
|
+ .filter(template -> template.isType("L2Npc"))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //@formatter:on
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -780,30 +763,23 @@ public class NpcData extends DocumentParser
|
|
*/
|
|
*/
|
|
public List<L2NpcTemplate> getAllNpcOfClassType(String... classTypes)
|
|
public List<L2NpcTemplate> getAllNpcOfClassType(String... classTypes)
|
|
{
|
|
{
|
|
- final List<L2NpcTemplate> list = new ArrayList<>();
|
|
|
|
- for (String classType : classTypes)
|
|
|
|
- {
|
|
|
|
- for (L2NpcTemplate t : _npcs.values())
|
|
|
|
- {
|
|
|
|
- if (t.isType(classType))
|
|
|
|
- {
|
|
|
|
- list.add(t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
|
|
+ //@formatter:off
|
|
|
|
+ return _npcs.values().stream()
|
|
|
|
+ .filter(template -> Util.contains(classTypes, template.getType(), true))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //@formatter:on
|
|
}
|
|
}
|
|
|
|
|
|
public void loadNpcsSkillLearn()
|
|
public void loadNpcsSkillLearn()
|
|
{
|
|
{
|
|
- for (L2NpcTemplate template : _npcs.values())
|
|
|
|
|
|
+ _npcs.values().forEach(template ->
|
|
{
|
|
{
|
|
final List<ClassId> teachInfo = SkillLearnData.getInstance().getSkillLearnData(template.getId());
|
|
final List<ClassId> teachInfo = SkillLearnData.getInstance().getSkillLearnData(template.getId());
|
|
if (teachInfo != null)
|
|
if (teachInfo != null)
|
|
{
|
|
{
|
|
template.addTeachInfo(teachInfo);
|
|
template.addTeachInfo(teachInfo);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
public void loadMinions()
|
|
public void loadMinions()
|