Replaced several CopyOnWriteArrayList occurrences with ConcurrentHashMap.newKeySet().

This commit is contained in:
MobiusDevelopment
2019-08-07 01:57:06 +00:00
parent c3a6557797
commit 9048735b73
395 changed files with 1430 additions and 1315 deletions

View File

@@ -17,10 +17,8 @@
package ai.bosses;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
@@ -88,14 +86,14 @@ public class Antharas extends Quest
}
};
protected List<Spawn> _teleportCubeSpawn = new CopyOnWriteArrayList<>();
protected List<NpcInstance> _teleportCube = new CopyOnWriteArrayList<>();
protected Collection<Spawn> _teleportCubeSpawn = ConcurrentHashMap.newKeySet();
protected Collection<NpcInstance> _teleportCube = ConcurrentHashMap.newKeySet();
// Spawn data of monsters.
protected Map<Integer, Spawn> _monsterSpawn = new ConcurrentHashMap<>();
// Instance of monsters.
protected List<NpcInstance> _monsters = new CopyOnWriteArrayList<>();
protected Collection<NpcInstance> _monsters = ConcurrentHashMap.newKeySet();
protected GrandBossInstance _antharas = null;
// monstersId

View File

@@ -16,11 +16,11 @@
*/
package ai.bosses;
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.commons.util.Rnd;
@@ -77,7 +77,7 @@ public class Core extends Quest
private static boolean _firstAttacked;
private static final List<Attackable> _minions = new CopyOnWriteArrayList<>();
private static final Collection<Attackable> _minions = ConcurrentHashMap.newKeySet();
public Core(int id, String name, String descr)
{
@@ -182,9 +182,8 @@ public class Core extends Quest
}
else if (event.equals("despawn_minions"))
{
for (int i = 0; i < _minions.size(); i++)
for (Attackable mob : _minions)
{
final Attackable mob = _minions.get(i);
if (mob != null)
{
mob.decayMe();

View File

@@ -16,8 +16,8 @@
*/
package ai.bosses;
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.commons.util.Rnd;
@@ -273,10 +273,10 @@ public class Frintezza extends Quest
private NpcInstance _portraitDummy1;
private NpcInstance _portraitDummy3;
private NpcInstance _scarletDummy;
private final List<PlayerInstance> _playersInside = new CopyOnWriteArrayList<>();
private final List<NpcInstance> _room1Monsters = new CopyOnWriteArrayList<>();
private final List<NpcInstance> _room2Monsters = new CopyOnWriteArrayList<>();
private final List<Attackable> _minions = new CopyOnWriteArrayList<>();
private final Collection<PlayerInstance> _playersInside = ConcurrentHashMap.newKeySet();
private final Collection<NpcInstance> _room1Monsters = ConcurrentHashMap.newKeySet();
private final Collection<NpcInstance> _room2Monsters = ConcurrentHashMap.newKeySet();
private final Collection<Attackable> _minions = ConcurrentHashMap.newKeySet();
// Boss: Frintezza
public Frintezza(int id, String name, String descr)
@@ -1407,9 +1407,8 @@ public class Frintezza extends Quest
{
synchronized (_minions)
{
for (int i = 0; i < _minions.size(); i++)
for (Attackable mob : _minions)
{
final Attackable mob = _minions.get(i);
if (mob != null)
{
mob.decayMe();
@@ -1479,7 +1478,7 @@ public class Frintezza extends Quest
htmltext = "<html><body>No reaction. Contact must be initiated by the Command Channel Leader.</body></html>";
party_check_success = false;
}
else if ((player.getParty().getCommandChannel().getPartys().size() < Config.FRINTEZZA_MIN_PARTIES) || (player.getParty().getCommandChannel().getPartys().size() > Config.FRINTEZZA_MAX_PARTIES))
else if ((player.getParty().getCommandChannel().getParties().size() < Config.FRINTEZZA_MIN_PARTIES) || (player.getParty().getCommandChannel().getParties().size() > Config.FRINTEZZA_MAX_PARTIES))
{
htmltext = "<html><body>Your command channel needs to have at least " + Config.FRINTEZZA_MIN_PARTIES + " parties and a maximum of " + Config.FRINTEZZA_MAX_PARTIES + ".</body></html>";
party_check_success = false;
@@ -1513,7 +1512,7 @@ public class Frintezza extends Quest
if (CC != null)
{ // teleport all parties into CC
for (Party party : CC.getPartys())
for (Party party : CC.getParties())
{
if (party == null)
{
@@ -1605,7 +1604,7 @@ public class Frintezza extends Quest
{
final CommandChannel CC = player.getParty().getCommandChannel();
for (Party party : CC.getPartys())
for (Party party : CC.getParties())
{
if (party == null)
{

View File

@@ -16,8 +16,8 @@
*/
package ai.bosses;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -35,7 +35,7 @@ public class Gustav extends Quest
private static final int GUSTAV = 35410;
private static final int MESSENGER = 35420;
// Misc
private static final List<Clan> _clans = new CopyOnWriteArrayList<>();
private static final Collection<Clan> _clans = ConcurrentHashMap.newKeySet();
private Gustav()
{

View File

@@ -16,8 +16,8 @@
*/
package ai.bosses;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import org.l2jmobius.Config;
@@ -48,7 +48,7 @@ public class IceFairySirra extends Quest
private static final int SILVER_HEMOCYTE = 8057;
private static BossZone _freyasZone;
private static PlayerInstance _player = null;
protected List<NpcInstance> _allMobs = new CopyOnWriteArrayList<>();
protected Collection<NpcInstance> _allMobs = ConcurrentHashMap.newKeySet();
protected Future<?> _onDeadEventTask = null;
public IceFairySirra(int id, String name, String descr)

View File

@@ -16,8 +16,8 @@
*/
package ai.bosses;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -35,7 +35,7 @@ public class Nurka extends Quest
private static final int NURKA = 35368;
private static final int MESSENGER = 35382;
// Misc
private static final List<Clan> _clans = new CopyOnWriteArrayList<>();
private static final Collection<Clan> _clans = ConcurrentHashMap.newKeySet();
private Nurka()
{

View File

@@ -20,11 +20,11 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
@@ -64,27 +64,27 @@ public class VanHalter extends Quest
// Spawn data of monsters.
protected Map<Integer, Spawn> _monsterSpawn = new ConcurrentHashMap<>();
protected List<Spawn> _royalGuardSpawn = new CopyOnWriteArrayList<>();
protected List<Spawn> _royalGuardCaptainSpawn = new CopyOnWriteArrayList<>();
protected List<Spawn> _royalGuardHelperSpawn = new CopyOnWriteArrayList<>();
protected List<Spawn> _triolRevelationSpawn = new CopyOnWriteArrayList<>();
protected List<Spawn> _triolRevelationAlive = new CopyOnWriteArrayList<>();
protected List<Spawn> _guardOfAltarSpawn = new CopyOnWriteArrayList<>();
protected Collection<Spawn> _royalGuardSpawn = ConcurrentHashMap.newKeySet();
protected Collection<Spawn> _royalGuardCaptainSpawn = ConcurrentHashMap.newKeySet();
protected Collection<Spawn> _royalGuardHelperSpawn = ConcurrentHashMap.newKeySet();
protected Collection<Spawn> _triolRevelationSpawn = ConcurrentHashMap.newKeySet();
protected Collection<Spawn> _triolRevelationAlive = ConcurrentHashMap.newKeySet();
protected Collection<Spawn> _guardOfAltarSpawn = ConcurrentHashMap.newKeySet();
protected Map<Integer, Spawn> _cameraMarkerSpawn = new ConcurrentHashMap<>();
protected Spawn _ritualOfferingSpawn = null;
protected Spawn _ritualSacrificeSpawn = null;
protected Spawn _vanHalterSpawn = null;
// Instance of monsters.
protected List<NpcInstance> _monsters = new CopyOnWriteArrayList<>();
protected List<NpcInstance> _royalGuard = new CopyOnWriteArrayList<>();
protected List<NpcInstance> _royalGuardCaptain = new CopyOnWriteArrayList<>();
protected List<NpcInstance> _royalGuardHepler = new CopyOnWriteArrayList<>();
protected List<NpcInstance> _triolRevelation = new CopyOnWriteArrayList<>();
protected List<NpcInstance> _guardOfAltar = new CopyOnWriteArrayList<>();
protected Collection<NpcInstance> _monsters = ConcurrentHashMap.newKeySet();
protected Collection<NpcInstance> _royalGuard = ConcurrentHashMap.newKeySet();
protected Collection<NpcInstance> _royalGuardCaptain = ConcurrentHashMap.newKeySet();
protected Collection<NpcInstance> _royalGuardHepler = ConcurrentHashMap.newKeySet();
protected Collection<NpcInstance> _triolRevelation = ConcurrentHashMap.newKeySet();
protected Collection<NpcInstance> _guardOfAltar = ConcurrentHashMap.newKeySet();
protected Map<Integer, NpcInstance> _cameraMarker = new ConcurrentHashMap<>();
protected List<DoorInstance> _doorOfAltar = new CopyOnWriteArrayList<>();
protected List<DoorInstance> _doorOfSacrifice = new CopyOnWriteArrayList<>();
protected Collection<DoorInstance> _doorOfAltar = ConcurrentHashMap.newKeySet();
protected Collection<DoorInstance> _doorOfSacrifice = ConcurrentHashMap.newKeySet();
protected NpcInstance _ritualOffering = null;
protected NpcInstance _ritualSacrifice = null;
protected RaidBossInstance _vanHalter = null;