Replaced several CopyOnWriteArrayList occurrences with ConcurrentHashMap.newKeySet().
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
package ai.areas.FantasyIsle;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -120,7 +121,7 @@ public class Parade extends AbstractNpcAI
|
||||
// @formatter:on
|
||||
|
||||
int npcIndex;
|
||||
CopyOnWriteArrayList<Npc> spawns = new CopyOnWriteArrayList<>();
|
||||
Collection<Npc> spawns = ConcurrentHashMap.newKeySet();
|
||||
ScheduledFuture<?> spawnTask;
|
||||
ScheduledFuture<?> deleteTask;
|
||||
ScheduledFuture<?> cleanTask;
|
||||
|
||||
@@ -18,8 +18,9 @@ package ai.areas.ForgeOfTheGods;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
@@ -189,7 +190,7 @@ public class TarBeetleSpawn implements IXmlReader
|
||||
private final class SpawnZone
|
||||
{
|
||||
private final List<Zone> _zones = new ArrayList<>();
|
||||
private final List<Npc> _spawn = new CopyOnWriteArrayList<>();
|
||||
private final Collection<Npc> _spawn = ConcurrentHashMap.newKeySet();
|
||||
private final int _maxNpcCount;
|
||||
private final int _index;
|
||||
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package ai.areas.Hellbound.AI.Zones.TowerOfNaia;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
@@ -158,7 +157,7 @@ public class TowerOfNaia extends AbstractNpcAI
|
||||
private int _winIndex;
|
||||
|
||||
private final Map<Integer, Boolean> _activeRooms = new HashMap<>();
|
||||
private final Map<Integer, List<Npc>> _spawns = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, Collection<Npc>> _spawns = new ConcurrentHashMap<>();
|
||||
private final Set<Npc> _sporeSpawn = ConcurrentHashMap.newKeySet();
|
||||
static
|
||||
{
|
||||
@@ -625,7 +624,7 @@ public class TowerOfNaia extends AbstractNpcAI
|
||||
|
||||
if ((managerId > 0) && _spawns.containsKey(managerId))
|
||||
{
|
||||
final List<Npc> spawned = _spawns.get(managerId);
|
||||
final Collection<Npc> spawned = _spawns.get(managerId);
|
||||
spawned.remove(npc);
|
||||
if (spawned.isEmpty() && DOORS.containsKey(managerId))
|
||||
{
|
||||
@@ -876,7 +875,7 @@ public class TowerOfNaia extends AbstractNpcAI
|
||||
if (SPAWNS.containsKey(managerId))
|
||||
{
|
||||
final int[][] spawnList = SPAWNS.get(managerId);
|
||||
final List<Npc> spawned = new CopyOnWriteArrayList<>();
|
||||
final Collection<Npc> spawned = ConcurrentHashMap.newKeySet();
|
||||
for (int[] spawn : spawnList)
|
||||
{
|
||||
final Npc spawnedNpc = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false);
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
*/
|
||||
package ai.bosses.Core;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
@@ -50,7 +50,7 @@ public class Core extends AbstractNpcAI
|
||||
private static final int DOOM_WRAITH = 29008;
|
||||
private static final int SUSCEPTOR = 29011;
|
||||
// Spawns
|
||||
private static final Map<Integer, Location> MINNION_SPAWNS = new HashMap<>();
|
||||
private static final Map<Integer, Location> MINNION_SPAWNS = new HashMap<>();
|
||||
static
|
||||
{
|
||||
MINNION_SPAWNS.put(DEATH_KNIGHT, new Location(17191, 109298, -6488));
|
||||
@@ -79,7 +79,7 @@ public class Core extends AbstractNpcAI
|
||||
|
||||
private static boolean _firstAttacked;
|
||||
|
||||
private static final List<Attackable> _minions = new CopyOnWriteArrayList<>();
|
||||
private static final Collection<Attackable> _minions = ConcurrentHashMap.newKeySet();
|
||||
|
||||
private Core()
|
||||
{
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package ai.bosses.Orfen;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
@@ -70,7 +70,7 @@ public class Orfen extends AbstractNpcAI
|
||||
private static final int RIBA_IREN = 29018;
|
||||
|
||||
private static boolean _IsTeleported;
|
||||
private static final List<Attackable> MINIONS = new CopyOnWriteArrayList<>();
|
||||
private static final Collection<Attackable> MINIONS = ConcurrentHashMap.newKeySet();
|
||||
private static BossZone ZONE;
|
||||
|
||||
private static final byte ALIVE = 0;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package ai.others;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
@@ -87,7 +87,7 @@ public class SiegeGuards extends AbstractNpcAI
|
||||
35134, 35135, 35136, 35176, 35177, 35178, 35218, 35219, 35220, 35261, 35262, 35263, 35264, 35265, 35308, 35309, 35310, 35352, 35353, 35354, 35497, 35498, 35499, 35500, 35501, 35544, 35545, 35546
|
||||
};
|
||||
//@formatter:on
|
||||
private static final List<Npc> SPAWNED_GUARDS = new CopyOnWriteArrayList<>();
|
||||
private static final Collection<Npc> SPAWNED_GUARDS = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public SiegeGuards()
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SteelCitadelTeleport extends AbstractNpcAI
|
||||
{
|
||||
GrandBossManager.getInstance().setBossStatus(BELETH, 1);
|
||||
|
||||
for (Party party : channel.getPartys())
|
||||
for (Party party : channel.getParties())
|
||||
{
|
||||
if (party == null)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
@@ -132,7 +132,7 @@ public class AdminTerritoryWar implements IAdminCommandHandler
|
||||
// get,build & send current Wards list
|
||||
if (TerritoryWarManager.getInstance().isTWInProgress())
|
||||
{
|
||||
final List<TerritoryWard> territoryWardList = TerritoryWarManager.getInstance().getAllTerritoryWards();
|
||||
final Collection<TerritoryWard> territoryWardList = TerritoryWarManager.getInstance().getAllTerritoryWards();
|
||||
for (TerritoryWard ward : territoryWardList)
|
||||
{
|
||||
if (ward.getNpc() != null)
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
|
||||
}
|
||||
if (!inst.getEnterLocs().isEmpty())
|
||||
{
|
||||
teleportPlayer(player, inst.getEnterLocs().get(getRandom(inst.getEnterLocs().size())), world.getInstanceId(), false);
|
||||
teleportPlayer(player, inst.getEnterLocs().stream().findAny().get(), world.getInstanceId(), false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
|
||||
}
|
||||
if (!inst.getEnterLocs().isEmpty())
|
||||
{
|
||||
teleportPlayer(player, inst.getEnterLocs().get(getRandom(inst.getEnterLocs().size())), instance.getInstanceId(), false);
|
||||
teleportPlayer(player, inst.getEnterLocs().stream().findAny().get(), instance.getInstanceId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user