diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 46115184af..a21f7f42f8 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 9ddbf358e8..59a5e26ca6 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 9ddbf358e8..59a5e26ca6 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 9ddbf358e8..59a5e26ca6 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 7d59fa9a00..9dc4b074bf 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 7d59fa9a00..9dc4b074bf 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 9ddbf358e8..59a5e26ca6 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 9ddbf358e8..59a5e26ca6 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 9ddbf358e8..59a5e26ca6 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 38e47fde03..c850f506b1 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 7d59fa9a00..9dc4b074bf 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 7d59fa9a00..9dc4b074bf 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 7d59fa9a00..9dc4b074bf 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); } diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 7d59fa9a00..9dc4b074bf 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -33,8 +33,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; @@ -65,6 +63,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.ILocational; import org.l2jmobius.gameserver.model.interfaces.INamable; +import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.SpawnGroup; import org.l2jmobius.gameserver.model.spawns.SpawnTemplate; import org.l2jmobius.gameserver.model.variables.PlayerVariables; @@ -112,7 +111,10 @@ public class Instance implements IIdentifiable, INamable _spawns = new ArrayList<>(template.getSpawns().size()); // Clone and add the spawn templates - template.getSpawns().stream().map(SpawnTemplate::clone).forEach(_spawns::add); + for (SpawnTemplate spawn : template.getSpawns()) + { + _spawns.add(spawn.clone()); + } // Register world to instance manager. InstanceManager.getInstance().register(this); @@ -454,7 +456,17 @@ public class Instance implements IIdentifiable, INamable */ public boolean isSpawnGroupExist(String name) { - return _spawns.stream().flatMap(group -> group.getGroups().stream()).anyMatch(group -> name.equalsIgnoreCase(group.getName())); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroups()) + { + if (name.equalsIgnoreCase(group.getName())) + { + return true; + } + } + } + return false; } /** @@ -483,30 +495,10 @@ public class Instance implements IIdentifiable, INamable /** * @param groupName - * @param filter + * @param filterValue * @return {@code List} of NPCs that are part of specified group and matches filter specified */ - public List getNpcsOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).collect(Collectors.toList()); - } - - /** - * @param groupName - * @param filter - * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified - */ - public Npc getNpcOfGroup(String groupName, Predicate filter) - { - return getStreamOfGroup(groupName, filter).findFirst().orElse(null); - } - - /** - * @param groupName - * @param filterValue - * @return {@code Stream} of NPCs that is part of a group and matches filter specified - */ - public Stream getStreamOfGroup(String groupName, Predicate filterValue) + public List getNpcsOfGroup(String groupName, Predicate filterValue) { Predicate filter = filterValue; if (filter == null) @@ -514,13 +506,56 @@ public class Instance implements IIdentifiable, INamable filter = Objects::nonNull; } - //@formatter:off - return _spawns.stream() - .flatMap(spawnTemplate -> spawnTemplate.getGroupsByName(groupName).stream()) - .flatMap(group -> group.getSpawns().stream()) - .flatMap(npcTemplate -> npcTemplate.getSpawnedNpcs().stream()) - .filter(filter); - //@formatter:on + final List npcs = new LinkedList<>(); + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + npcs.add(npc); + } + } + } + } + } + return npcs; + } + + /** + * @param groupName + * @param filterValue + * @return {@code Npc} instance of an NPC that is part of a group and matches filter specified + */ + public Npc getNpcOfGroup(String groupName, Predicate filterValue) + { + Predicate filter = filterValue; + if (filter == null) + { + filter = Objects::nonNull; + } + + for (SpawnTemplate spawnTemplate : _spawns) + { + for (SpawnGroup group : spawnTemplate.getGroupsByName(groupName)) + { + for (NpcSpawnTemplate npcTemplate : group.getSpawns()) + { + for (Npc npc : npcTemplate.getSpawnedNpcs()) + { + if (filter.test(npc)) + { + return npc; + } + } + } + } + } + return null; } /** @@ -758,7 +793,13 @@ public class Instance implements IIdentifiable, INamable */ private void removeDoors() { - _doors.values().stream().filter(Objects::nonNull).forEach(Door::decayMe); + for (Door door : _doors.values()) + { + if (door != null) + { + door.decayMe(); + } + } _doors.clear(); }