Replaced several CopyOnWriteArrayList occurrences with ConcurrentHashMap.newKeySet().
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,15 +19,15 @@ package org.l2jmobius.gameserver.communitybbs.Manager;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.communitybbs.BB.Forum;
|
||||
|
||||
public class ForumsBBSManager extends BaseBBSManager
|
||||
{
|
||||
private final List<Forum> _table;
|
||||
private final Collection<Forum> _table;
|
||||
private int _lastid = 1;
|
||||
|
||||
public static ForumsBBSManager getInstance()
|
||||
@@ -37,7 +37,7 @@ public class ForumsBBSManager extends BaseBBSManager
|
||||
|
||||
protected ForumsBBSManager()
|
||||
{
|
||||
_table = new CopyOnWriteArrayList<>();
|
||||
_table = ConcurrentHashMap.newKeySet();
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -70,7 +71,7 @@ public class GrandBossManager
|
||||
|
||||
private Map<Integer, Integer> _bossStatus;
|
||||
|
||||
private List<BossZone> _zones;
|
||||
private Collection<BossZone> _zones;
|
||||
|
||||
public static GrandBossManager getInstance()
|
||||
{
|
||||
@@ -89,7 +90,7 @@ public class GrandBossManager
|
||||
|
||||
private void init()
|
||||
{
|
||||
_zones = new CopyOnWriteArrayList<>();
|
||||
_zones = ConcurrentHashMap.newKeySet();
|
||||
_bosses = new ConcurrentHashMap<>();
|
||||
_storedInfo = new ConcurrentHashMap<>();
|
||||
_bossStatus = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
|
||||
@@ -35,7 +37,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
*/
|
||||
public class CommandChannel
|
||||
{
|
||||
private final List<Party> _parties;
|
||||
private final Collection<Party> _parties;
|
||||
private PlayerInstance _commandLeader = null;
|
||||
private int _channelLvl;
|
||||
|
||||
@@ -46,7 +48,7 @@ public class CommandChannel
|
||||
public CommandChannel(PlayerInstance leader)
|
||||
{
|
||||
_commandLeader = leader;
|
||||
_parties = new ArrayList<>();
|
||||
_parties = ConcurrentHashMap.newKeySet();
|
||||
_parties.add(leader.getParty());
|
||||
_channelLvl = leader.getParty().getLevel();
|
||||
leader.getParty().setCommandChannel(this);
|
||||
@@ -179,7 +181,7 @@ public class CommandChannel
|
||||
/**
|
||||
* @return list of Parties in Command Channel
|
||||
*/
|
||||
public List<Party> getPartys()
|
||||
public Collection<Party> getParties()
|
||||
{
|
||||
return _parties;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class ExMultiPartyCommandChannelInfo extends GameServerPacket
|
||||
writeD(0); // Channel loot
|
||||
writeD(_channel.getMemberCount());
|
||||
|
||||
writeD(_channel.getPartys().size());
|
||||
for (Party p : _channel.getPartys())
|
||||
writeD(_channel.getParties().size());
|
||||
for (Party p : _channel.getParties())
|
||||
{
|
||||
writeS(p.getLeader().getName());
|
||||
writeD(p.getPartyLeaderOID());
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.thread.daemons;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -31,12 +31,12 @@ public class ItemsAutoDestroy
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroy.class.getName());
|
||||
private static ItemsAutoDestroy _instance;
|
||||
protected List<ItemInstance> _items = null;
|
||||
protected Collection<ItemInstance> _items = null;
|
||||
protected static long _sleep;
|
||||
|
||||
private ItemsAutoDestroy()
|
||||
{
|
||||
_items = new CopyOnWriteArrayList<>();
|
||||
_items = ConcurrentHashMap.newKeySet();
|
||||
_sleep = Config.AUTODESTROY_ITEM_AFTER * 1000;
|
||||
if (_sleep == 0)
|
||||
{
|
||||
|
||||
@@ -29,11 +29,9 @@ import java.sql.ResultSet;
|
||||
import java.util.Base64;
|
||||
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.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
@@ -99,7 +97,7 @@ public class LoginController
|
||||
private static final int LOGIN_TIMEOUT = 60 * 1000;
|
||||
|
||||
/** Clients that are on the LS but arent assocated with a account yet */
|
||||
protected List<LoginClient> _clients = new CopyOnWriteArrayList<>();
|
||||
protected Collection<LoginClient> _clients = ConcurrentHashMap.newKeySet();
|
||||
|
||||
/** Authed Clients on LoginServer */
|
||||
protected Map<String, LoginClient> _loginServerClients = new ConcurrentHashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user