Sync with L2jServer HighFive Mar 25th 2015.

This commit is contained in:
MobiusDev
2015-03-25 06:48:51 +00:00
parent e0c66b1412
commit 82606870c0
194 changed files with 2619 additions and 2869 deletions

View File

@@ -23,9 +23,11 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
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.concurrent.TimeUnit;
import java.util.logging.Level;
@@ -65,16 +67,13 @@ public class AutoSpawnHandler
private static final int DEFAULT_RESPAWN = 3600000; // 1 hour in millisecs
private static final int DEFAULT_DESPAWN = 3600000; // 1 hour in millisecs
protected Map<Integer, AutoSpawnInstance> _registeredSpawns;
protected Map<Integer, ScheduledFuture<?>> _runningSpawns;
protected Map<Integer, AutoSpawnInstance> _registeredSpawns = new ConcurrentHashMap<>();
protected Map<Integer, ScheduledFuture<?>> _runningSpawns = new ConcurrentHashMap<>();
protected boolean _activeState = true;
protected AutoSpawnHandler()
{
_registeredSpawns = new HashMap<>();
_runningSpawns = new HashMap<>();
restoreSpawnData();
}
@@ -108,8 +107,8 @@ public class AutoSpawnHandler
}
// create clean list
_registeredSpawns = new HashMap<>();
_runningSpawns = new HashMap<>();
_registeredSpawns.clear();
_runningSpawns.clear();
// load
restoreSpawnData();
@@ -367,19 +366,17 @@ public class AutoSpawnHandler
return null;
}
public Map<Integer, AutoSpawnInstance> getAutoSpawnInstances(int npcId)
public List<AutoSpawnInstance> getAutoSpawnInstances(int npcId)
{
Map<Integer, AutoSpawnInstance> spawnInstList = new HashMap<>();
final List<AutoSpawnInstance> result = new LinkedList<>();
for (AutoSpawnInstance spawnInst : _registeredSpawns.values())
{
if (spawnInst.getId() == npcId)
{
spawnInstList.put(spawnInst.getObjectId(), spawnInst);
result.add(spawnInst);
}
}
return spawnInstList;
return result;
}
/**
@@ -595,9 +592,9 @@ public class AutoSpawnHandler
protected int _lastLocIndex = -1;
private final List<L2Npc> _npcList = new ArrayList<>();
private final List<L2Npc> _npcList = new CopyOnWriteArrayList<>();
private final List<Location> _locList = new ArrayList<>();
private final List<Location> _locList = new CopyOnWriteArrayList<>();
private boolean _spawnActive;
@@ -680,16 +677,14 @@ public class AutoSpawnHandler
return ret;
}
public L2Spawn[] getSpawns()
public List<L2Spawn> getSpawns()
{
List<L2Spawn> npcSpawns = new ArrayList<>();
final List<L2Spawn> npcSpawns = new ArrayList<>();
for (L2Npc npcInst : _npcList)
{
npcSpawns.add(npcInst.getSpawn());
}
return npcSpawns.toArray(new L2Spawn[npcSpawns.size()]);
return npcSpawns;
}
public void setSpawnCount(int spawnCount)

View File

@@ -35,14 +35,10 @@ import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.friend.BlockListPacket;
/**
* This class ...
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
*/
public class BlockList
{
private static Logger _log = Logger.getLogger(BlockList.class.getName());
private static Map<Integer, HashMap<Integer, String>> _offlineList = new HashMap<>();
private static Map<Integer, HashMap<Integer, String>> OFFLINE_LIST = new HashMap<>();
private final L2PcInstance _owner;
private HashMap<Integer, String> _blockList;
@@ -51,7 +47,7 @@ public class BlockList
public BlockList(L2PcInstance owner)
{
_owner = owner;
_blockList = _offlineList.get(owner.getObjectId());
_blockList = OFFLINE_LIST.get(owner.getObjectId());
if (_blockList == null)
{
_blockList = loadList(_owner.getObjectId());
@@ -108,7 +104,7 @@ public class BlockList
public void playerLogout()
{
_offlineList.put(_owner.getObjectId(), _blockList);
OFFLINE_LIST.put(_owner.getObjectId(), _blockList);
}
private static HashMap<Integer, String> loadList(int ObjId)
@@ -303,10 +299,10 @@ public class BlockList
{
return BlockList.isBlocked(player, targetId);
}
if (!_offlineList.containsKey(ownerId))
if (!OFFLINE_LIST.containsKey(ownerId))
{
_offlineList.put(ownerId, loadList(ownerId));
OFFLINE_LIST.put(ownerId, loadList(ownerId));
}
return _offlineList.get(ownerId).containsKey(targetId);
return OFFLINE_LIST.get(ownerId).containsKey(targetId);
}
}

View File

@@ -23,9 +23,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -62,18 +63,18 @@ import com.l2jserver.gameserver.network.serverpackets.ShortBuffStatusUpdate;
public final class CharEffectList
{
private static final Logger _log = Logger.getLogger(CharEffectList.class.getName());
/** Map containing all effects from buffs for this effect list. */
private volatile ConcurrentHashMap<Integer, BuffInfo> _buffs;
/** Map containing all triggered skills for this effect list. */
private volatile ConcurrentHashMap<Integer, BuffInfo> _triggered;
/** Map containing all dances/songs for this effect list. */
private volatile ConcurrentHashMap<Integer, BuffInfo> _dances;
/** Map containing all toggle for this effect list. */
private volatile ConcurrentHashMap<Integer, BuffInfo> _toggles;
/** Map containing all debuffs for this effect list. */
private volatile ConcurrentHashMap<Integer, BuffInfo> _debuffs;
/** They bypass most of the actions, they are not included in most operations. */
private volatile ConcurrentHashMap<Integer, BuffInfo> _passives;
/** Queue containing all effects from buffs for this effect list. */
private volatile Queue<BuffInfo> _buffs;
/** Queue containing all triggered skills for this effect list. */
private volatile Queue<BuffInfo> _triggered;
/** Queue containing all dances/songs for this effect list. */
private volatile Queue<BuffInfo> _dances;
/** Queue containing all toggle for this effect list. */
private volatile Queue<BuffInfo> _toggles;
/** Queue containing all debuffs for this effect list. */
private volatile Queue<BuffInfo> _debuffs;
/** Queue containing all passives for this effect list. They bypass most of the actions and they are not included in most operations. */
private volatile Queue<BuffInfo> _passives;
/** Map containing the all stacked effect in progress for each abnormal type. */
private volatile Map<AbnormalType, BuffInfo> _stackedEffects;
/** Set containing all abnormal types that shouldn't be added to this creature effect list. */
@@ -108,7 +109,7 @@ public final class CharEffectList
* Gets buff skills.
* @return the buff skills
*/
public Map<Integer, BuffInfo> getBuffs()
public Queue<BuffInfo> getBuffs()
{
if (_buffs == null)
{
@@ -116,7 +117,7 @@ public final class CharEffectList
{
if (_buffs == null)
{
_buffs = new ConcurrentHashMap<>();
_buffs = new ConcurrentLinkedQueue<>();
}
}
}
@@ -127,7 +128,7 @@ public final class CharEffectList
* Gets triggered skill skills.
* @return the triggered skill skills
*/
public Map<Integer, BuffInfo> getTriggered()
public Queue<BuffInfo> getTriggered()
{
if (_triggered == null)
{
@@ -135,7 +136,7 @@ public final class CharEffectList
{
if (_triggered == null)
{
_triggered = new ConcurrentHashMap<>();
_triggered = new ConcurrentLinkedQueue<>();
}
}
}
@@ -146,7 +147,7 @@ public final class CharEffectList
* Gets dance/song skills.
* @return the dance/song skills
*/
public Map<Integer, BuffInfo> getDances()
public Queue<BuffInfo> getDances()
{
if (_dances == null)
{
@@ -154,7 +155,7 @@ public final class CharEffectList
{
if (_dances == null)
{
_dances = new ConcurrentHashMap<>();
_dances = new ConcurrentLinkedQueue<>();
}
}
}
@@ -165,7 +166,7 @@ public final class CharEffectList
* Gets toggle skills.
* @return the toggle skills
*/
public Map<Integer, BuffInfo> getToggles()
public Queue<BuffInfo> getToggles()
{
if (_toggles == null)
{
@@ -173,7 +174,7 @@ public final class CharEffectList
{
if (_toggles == null)
{
_toggles = new ConcurrentHashMap<>();
_toggles = new ConcurrentLinkedQueue<>();
}
}
}
@@ -184,7 +185,7 @@ public final class CharEffectList
* Gets debuff skills.
* @return the debuff skills
*/
public Map<Integer, BuffInfo> getDebuffs()
public Queue<BuffInfo> getDebuffs()
{
if (_debuffs == null)
{
@@ -192,7 +193,7 @@ public final class CharEffectList
{
if (_debuffs == null)
{
_debuffs = new ConcurrentHashMap<>();
_debuffs = new ConcurrentLinkedQueue<>();
}
}
}
@@ -203,7 +204,7 @@ public final class CharEffectList
* Gets passive skills.
* @return the passive skills
*/
public Map<Integer, BuffInfo> getPassives()
public Queue<BuffInfo> getPassives()
{
if (_passives == null)
{
@@ -211,7 +212,7 @@ public final class CharEffectList
{
if (_passives == null)
{
_passives = new ConcurrentHashMap<>();
_passives = new ConcurrentLinkedQueue<>();
}
}
}
@@ -232,27 +233,27 @@ public final class CharEffectList
final List<BuffInfo> buffs = new ArrayList<>();
if (hasBuffs())
{
buffs.addAll(getBuffs().values());
buffs.addAll(getBuffs());
}
if (hasTriggered())
{
buffs.addAll(getTriggered().values());
buffs.addAll(getTriggered());
}
if (hasDances())
{
buffs.addAll(getDances().values());
buffs.addAll(getDances());
}
if (hasToggles())
{
buffs.addAll(getToggles().values());
buffs.addAll(getToggles());
}
if (hasDebuffs())
{
buffs.addAll(getDebuffs().values());
buffs.addAll(getDebuffs());
}
return buffs;
}
@@ -262,14 +263,14 @@ public final class CharEffectList
* @param skill the skill
* @return the effect list
*/
private Map<Integer, BuffInfo> getEffectList(Skill skill)
private Queue<BuffInfo> getEffectList(Skill skill)
{
if (skill == null)
{
return null;
}
final Map<Integer, BuffInfo> effects;
final Queue<BuffInfo> effects;
if (skill.isPassive())
{
effects = getPassives();
@@ -308,7 +309,7 @@ public final class CharEffectList
{
if (hasBuffs())
{
for (BuffInfo info : getBuffs().values())
for (BuffInfo info : getBuffs())
{
if (info != null)
{
@@ -325,7 +326,7 @@ public final class CharEffectList
if (hasTriggered())
{
for (BuffInfo info : getTriggered().values())
for (BuffInfo info : getTriggered())
{
if (info != null)
{
@@ -342,7 +343,7 @@ public final class CharEffectList
if (hasDances())
{
for (BuffInfo info : getDances().values())
for (BuffInfo info : getDances())
{
if (info != null)
{
@@ -359,7 +360,7 @@ public final class CharEffectList
if (hasToggles())
{
for (BuffInfo info : getToggles().values())
for (BuffInfo info : getToggles())
{
if (info != null)
{
@@ -376,7 +377,7 @@ public final class CharEffectList
if (hasDebuffs())
{
for (BuffInfo info : getDebuffs().values())
for (BuffInfo info : getDebuffs())
{
if (info != null)
{
@@ -401,7 +402,7 @@ public final class CharEffectList
*/
public boolean isAffectedBySkill(int skillId)
{
return (hasBuffs() && getBuffs().containsKey(skillId)) || (hasDebuffs() && getDebuffs().containsKey(skillId)) || (hasTriggered() && getTriggered().containsKey(skillId)) || (hasDances() && getDances().containsKey(skillId)) || (hasToggles() && getToggles().containsKey(skillId)) || (hasPassives() && getPassives().containsKey(skillId));
return getBuffInfoBySkillId(skillId) != null;
}
/**
@@ -413,29 +414,34 @@ public final class CharEffectList
public BuffInfo getBuffInfoBySkillId(int skillId)
{
BuffInfo info = null;
if (hasBuffs() && getBuffs().containsKey(skillId))
if (hasBuffs())
{
info = getBuffs().get(skillId);
info = getBuffs().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null);
}
else if (hasTriggered() && getTriggered().containsKey(skillId))
if (hasTriggered() && (info == null))
{
info = getTriggered().get(skillId);
info = getTriggered().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null);
}
else if (hasDances() && getDances().containsKey(skillId))
if (hasDances() && (info == null))
{
info = getDances().get(skillId);
info = getDances().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null);
}
else if (hasToggles() && getToggles().containsKey(skillId))
if (hasToggles() && (info == null))
{
info = getToggles().get(skillId);
info = getToggles().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null);
}
else if (hasDebuffs() && getDebuffs().containsKey(skillId))
if (hasDebuffs() && (info == null))
{
info = getDebuffs().get(skillId);
info = getDebuffs().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null);
}
else if (hasPassives() && getPassives().containsKey(skillId))
if (hasPassives() && (info == null))
{
info = getPassives().get(skillId);
info = getPassives().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null);
}
return info;
}
@@ -463,7 +469,7 @@ public final class CharEffectList
{
if (_blockedBuffSlots == null)
{
_blockedBuffSlots = new CopyOnWriteArraySet<>();
_blockedBuffSlots = ConcurrentHashMap.newKeySet(blockedBuffSlots.size());
}
}
}
@@ -535,13 +541,8 @@ public final class CharEffectList
return false;
}
final Map<Integer, BuffInfo> effects = getEffectList(skill);
if ((effects == null) || effects.isEmpty())
{
return false;
}
for (BuffInfo info : effects.values())
final Queue<BuffInfo> effects = getEffectList(skill);
for (BuffInfo info : effects)
{
if ((info != null) && (info.getSkill().getAbnormalType() == type))
{
@@ -604,7 +605,7 @@ public final class CharEffectList
* @param info the buff info
* @param effects the effect list
*/
protected void stopAndRemove(BuffInfo info, Map<Integer, BuffInfo> effects)
protected void stopAndRemove(BuffInfo info, Queue<BuffInfo> effects)
{
stopAndRemove(true, info, effects);
}
@@ -615,7 +616,7 @@ public final class CharEffectList
* @param info the buff info
* @param buffs the buff list
*/
private void stopAndRemove(boolean removed, BuffInfo info, Map<Integer, BuffInfo> buffs)
private void stopAndRemove(boolean removed, BuffInfo info, Queue<BuffInfo> buffs)
{
if (info == null)
{
@@ -623,7 +624,7 @@ public final class CharEffectList
}
// Removes the buff from the given effect list.
buffs.remove(info.getSkill().getId());
buffs.remove(info);
// Stop the buff effects.
info.stopAllEffects(removed);
// If it's a hidden buff that ends, then decrease hidden buff count.
@@ -640,7 +641,7 @@ public final class CharEffectList
// If it's an herb that ends, check if there are hidden buffs.
if (info.getSkill().isAbnormalInstant() && hasBuffs())
{
for (BuffInfo buff : getBuffs().values())
for (BuffInfo buff : getBuffs())
{
if ((buff != null) && (buff.getSkill().getAbnormalType() == info.getSkill().getAbnormalType()) && !buff.isInUse())
{
@@ -698,31 +699,31 @@ public final class CharEffectList
boolean update = false;
if (hasBuffs())
{
getBuffs().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getBuffs()));
getBuffs().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true;
}
if (hasTriggered())
{
getTriggered().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getTriggered()));
getTriggered().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true;
}
if (hasDebuffs())
{
getDebuffs().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDebuffs()));
getDebuffs().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true;
}
if (hasDances())
{
getDances().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDances()));
getDances().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDances()));
update = true;
}
if (hasToggles())
{
getToggles().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getToggles()));
getToggles().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getToggles()));
update = true;
}
@@ -738,31 +739,31 @@ public final class CharEffectList
boolean update = false;
if (hasBuffs())
{
getBuffs().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getBuffs()));
getBuffs().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true;
}
if (hasTriggered())
{
getTriggered().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getTriggered()));
getTriggered().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true;
}
if (hasDebuffs())
{
getDebuffs().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDebuffs()));
getDebuffs().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true;
}
if (hasDances())
{
getDances().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDances()));
getDances().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDances()));
update = true;
}
if (hasToggles())
{
getToggles().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getToggles()));
getToggles().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getToggles()));
update = true;
}
@@ -779,12 +780,12 @@ public final class CharEffectList
{
if (hasBuffs())
{
getBuffs().forEach((k, info) -> stopAndRemove(info, getBuffs()));
getBuffs().forEach(b -> stopAndRemove(b, getBuffs()));
}
if (triggered && hasTriggered())
{
getTriggered().forEach((k, info) -> stopAndRemove(info, getTriggered()));
getTriggered().forEach(b -> stopAndRemove(b, getTriggered()));
}
// Update effect flags and icons.
@@ -808,7 +809,7 @@ public final class CharEffectList
{
if (hasToggles())
{
getToggles().forEach((k, info) -> stopAndRemove(info, getToggles()));
getToggles().forEach(b -> stopAndRemove(b, getToggles()));
// Update effect flags and icons.
updateEffectList(update);
}
@@ -822,7 +823,7 @@ public final class CharEffectList
{
if (hasDances())
{
getDances().forEach((k, info) -> stopAndRemove(info, getDances()));
getDances().forEach(b -> stopAndRemove(b, getDances()));
// Update effect flags and icons.
updateEffectList(update);
}
@@ -836,7 +837,7 @@ public final class CharEffectList
{
if (hasDebuffs())
{
getDebuffs().forEach((k, info) -> stopAndRemove(info, getDebuffs()));
getDebuffs().forEach(b -> stopAndRemove(b, getDebuffs()));
// Update effect flags and icons.
updateEffectList(update);
}
@@ -860,31 +861,31 @@ public final class CharEffectList
if (hasBuffs())
{
getBuffs().values().stream().filter(Objects::nonNull).forEach(action);
getBuffs().stream().filter(Objects::nonNull).forEach(action);
update = true;
}
if (hasTriggered())
{
getTriggered().values().stream().filter(Objects::nonNull).forEach(action);
getTriggered().stream().filter(Objects::nonNull).forEach(action);
update = true;
}
if (hasDances())
{
getDances().values().stream().filter(Objects::nonNull).forEach(action);
getDances().stream().filter(Objects::nonNull).forEach(action);
update = true;
}
if (hasToggles())
{
getToggles().values().stream().filter(Objects::nonNull).forEach(action);
getToggles().stream().filter(Objects::nonNull).forEach(action);
update = true;
}
if (hasDebuffs())
{
getDebuffs().values().stream().filter(Objects::nonNull).forEach(action);
getDebuffs().stream().filter(Objects::nonNull).forEach(action);
update = true;
}
@@ -908,7 +909,7 @@ public final class CharEffectList
final BuffInfo info = getBuffInfoBySkillId(skillId);
if (info != null)
{
stopSkillEffects(removed, info.getSkill());
remove(removed, info);
}
}
@@ -925,15 +926,9 @@ public final class CharEffectList
*/
public void stopSkillEffects(boolean removed, Skill skill)
{
if ((skill == null) || !isAffectedBySkill(skill.getId()))
if (skill != null)
{
return;
}
final Map<Integer, BuffInfo> effects = getEffectList(skill);
if (effects != null)
{
remove(removed, effects.get(skill.getId()));
stopSkillEffects(removed, skill.getId());
}
}
@@ -972,31 +967,31 @@ public final class CharEffectList
boolean update = false;
if (hasBuffs())
{
getBuffs().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getBuffs()));
getBuffs().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true;
}
if (hasTriggered())
{
getTriggered().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getTriggered()));
getTriggered().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true;
}
if (hasDebuffs())
{
getDebuffs().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDebuffs()));
getDebuffs().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true;
}
if (hasDances())
{
getDances().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDances()));
getDances().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDances()));
update = true;
}
if (hasToggles())
{
getToggles().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getToggles()));
getToggles().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getToggles()));
update = true;
}
@@ -1014,25 +1009,25 @@ public final class CharEffectList
{
if (hasBuffs())
{
getBuffs().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getBuffs()));
getBuffs().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true;
}
if (hasTriggered())
{
getTriggered().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getTriggered()));
getTriggered().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true;
}
if (hasDances())
{
getDances().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDances()));
getDances().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDances()));
update = true;
}
if (hasToggles())
{
getToggles().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getToggles()));
getToggles().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getToggles()));
update = true;
}
}
@@ -1041,7 +1036,7 @@ public final class CharEffectList
{
if (hasDebuffs())
{
getDebuffs().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDebuffs()));
getDebuffs().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true;
}
}
@@ -1144,7 +1139,7 @@ public final class CharEffectList
boolean update = false;
if (hasBuffs())
{
for (BuffInfo info : getBuffs().values())
for (BuffInfo info : getBuffs())
{
update |= function.apply(info);
}
@@ -1152,7 +1147,7 @@ public final class CharEffectList
if (hasTriggered())
{
for (BuffInfo info : getTriggered().values())
for (BuffInfo info : getTriggered())
{
update |= function.apply(info);
}
@@ -1160,7 +1155,7 @@ public final class CharEffectList
if (dances && hasDances())
{
for (BuffInfo info : getDances().values())
for (BuffInfo info : getDances())
{
update |= function.apply(info);
}
@@ -1168,7 +1163,7 @@ public final class CharEffectList
if (hasToggles())
{
for (BuffInfo info : getToggles().values())
for (BuffInfo info : getToggles())
{
update |= function.apply(info);
}
@@ -1176,7 +1171,7 @@ public final class CharEffectList
if (hasDebuffs())
{
for (BuffInfo info : getDebuffs().values())
for (BuffInfo info : getDebuffs())
{
update |= function.apply(info);
}
@@ -1192,7 +1187,7 @@ public final class CharEffectList
*/
public void remove(boolean removed, BuffInfo info)
{
if ((info == null) || !isAffectedBySkill(info.getSkill().getId()))
if (info == null)
{
return;
}
@@ -1237,13 +1232,15 @@ public final class CharEffectList
}
// Puts the effects in the list.
final BuffInfo infoToRemove = getPassives().put(skill.getId(), info);
if (infoToRemove != null)
getPassives().stream().filter(b -> b.getSkill().getId() == skill.getId()).forEach(b ->
{
// Removes the old stats from the creature if the skill was present.
infoToRemove.setInUse(false);
infoToRemove.removeStats();
}
b.setInUse(false);
b.removeStats();
getPassives().remove(b);
});
getPassives().add(info);
// Initialize effects.
info.initializeEffects();
@@ -1323,7 +1320,7 @@ public final class CharEffectList
}
// Select the map that holds the effects related to this skill.
final Map<Integer, BuffInfo> effects = getEffectList(skill);
final Queue<BuffInfo> effects = getEffectList(skill);
// Remove first buff when buff list is full.
if (!skill.isDebuff() && !skill.isToggle() && !skill.is7Signs() && !doesStack(skill))
{
@@ -1341,7 +1338,7 @@ public final class CharEffectList
buffsToRemove = getBuffCount() - _owner.getStat().getMaxBuffCount();
}
for (BuffInfo bi : effects.values())
for (BuffInfo bi : effects)
{
if (buffsToRemove < 0)
{
@@ -1361,7 +1358,7 @@ public final class CharEffectList
// After removing old buff (same ID) or stacked buff (same abnormal type),
// Add the buff to the end of the effect list.
effects.put(skill.getId(), info);
effects.add(info);
// Initialize effects.
info.initializeEffects();
// Update effect flags and icons.
@@ -1423,7 +1420,7 @@ public final class CharEffectList
// Buffs.
if (hasBuffs())
{
for (BuffInfo info : getBuffs().values())
for (BuffInfo info : getBuffs())
{
if (info.getSkill().isHealingPotionSkill())
{
@@ -1439,7 +1436,7 @@ public final class CharEffectList
// Triggered buffs.
if (hasTriggered())
{
for (BuffInfo info : getTriggered().values())
for (BuffInfo info : getTriggered())
{
addIcon(info, asu, ps, psSummon, os, isSummon);
}
@@ -1448,7 +1445,7 @@ public final class CharEffectList
// Songs and dances.
if (hasDances())
{
for (BuffInfo info : getDances().values())
for (BuffInfo info : getDances())
{
addIcon(info, asu, ps, psSummon, os, isSummon);
}
@@ -1457,7 +1454,7 @@ public final class CharEffectList
// Songs and dances.
if (hasToggles())
{
for (BuffInfo info : getToggles().values())
for (BuffInfo info : getToggles())
{
addIcon(info, asu, ps, psSummon, os, isSummon);
}
@@ -1466,7 +1463,7 @@ public final class CharEffectList
// Debuffs.
if (hasDebuffs())
{
for (BuffInfo info : getDebuffs().values())
for (BuffInfo info : getDebuffs())
{
addIcon(info, asu, ps, psSummon, os, isSummon);
}
@@ -1583,7 +1580,7 @@ public final class CharEffectList
{
if (hasBuffs())
{
for (BuffInfo info : getBuffs().values())
for (BuffInfo info : getBuffs())
{
if (info == null)
{
@@ -1604,7 +1601,7 @@ public final class CharEffectList
if (hasTriggered())
{
for (BuffInfo info : getTriggered().values())
for (BuffInfo info : getTriggered())
{
if (info == null)
{
@@ -1625,7 +1622,7 @@ public final class CharEffectList
if (hasToggles())
{
for (BuffInfo info : getToggles().values())
for (BuffInfo info : getToggles())
{
if (info == null)
{
@@ -1646,7 +1643,7 @@ public final class CharEffectList
if (hasDebuffs())
{
for (BuffInfo info : getDebuffs().values())
for (BuffInfo info : getDebuffs())
{
if ((info != null) && info.getSkill().isRemovedOnDamage())
{
@@ -1665,7 +1662,7 @@ public final class CharEffectList
int flags = 0;
if (hasBuffs())
{
for (BuffInfo info : getBuffs().values())
for (BuffInfo info : getBuffs())
{
if (info != null)
{
@@ -1679,7 +1676,7 @@ public final class CharEffectList
if (hasTriggered())
{
for (BuffInfo info : getTriggered().values())
for (BuffInfo info : getTriggered())
{
if (info != null)
{
@@ -1693,7 +1690,7 @@ public final class CharEffectList
if (hasDebuffs())
{
for (BuffInfo info : getDebuffs().values())
for (BuffInfo info : getDebuffs())
{
if (info != null)
{
@@ -1707,7 +1704,7 @@ public final class CharEffectList
if (hasDances())
{
for (BuffInfo info : getDances().values())
for (BuffInfo info : getDances())
{
if (info != null)
{
@@ -1721,7 +1718,7 @@ public final class CharEffectList
if (hasToggles())
{
for (BuffInfo info : getToggles().values())
for (BuffInfo info : getToggles())
{
if (info != null)
{

View File

@@ -25,8 +25,11 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -109,7 +112,7 @@ public class L2Clan implements IIdentifiable, INamable
private String _name;
private int _clanId;
private L2ClanMember _leader;
private final Map<Integer, L2ClanMember> _members = new HashMap<>();
private final Map<Integer, L2ClanMember> _members = new ConcurrentHashMap<>();
private String _allyName;
private int _allyId;
@@ -130,16 +133,16 @@ public class L2Clan implements IIdentifiable, INamable
private int _bloodOathCount;
private final ItemContainer _warehouse = new ClanWarehouse(this);
private final List<Integer> _atWarWith = new ArrayList<>();
private final List<Integer> _atWarAttackers = new ArrayList<>();
private final List<Integer> _atWarWith = new CopyOnWriteArrayList<>();
private final List<Integer> _atWarAttackers = new CopyOnWriteArrayList<>();
private Forum _forum;
/** HashMap(Integer, L2Skill) containing all skills of the L2Clan */
private final Map<Integer, Skill> _skills = new HashMap<>();
private final Map<Integer, RankPrivs> _privs = new HashMap<>();
private final Map<Integer, SubPledge> _subPledges = new HashMap<>();
private final Map<Integer, Skill> _subPledgeSkills = new HashMap<>();
/** Map(Integer, L2Skill) containing all skills of the L2Clan */
private final Map<Integer, Skill> _skills = new ConcurrentHashMap<>();
private final Map<Integer, RankPrivs> _privs = new ConcurrentHashMap<>();
private final Map<Integer, SubPledge> _subPledges = new ConcurrentHashMap<>();
private final Map<Integer, Skill> _subPledgeSkills = new ConcurrentHashMap<>();
private int _reputationScore = 0;
private int _rank = 0;
@@ -609,9 +612,9 @@ public class L2Clan implements IIdentifiable, INamable
* @param exclude the object Id to exclude from list.
* @return all online members excluding the one with object id {code exclude}.
*/
public ArrayList<L2PcInstance> getOnlineMembers(int exclude)
public List<L2PcInstance> getOnlineMembers(int exclude)
{
final ArrayList<L2PcInstance> onlineMembers = new ArrayList<>();
final List<L2PcInstance> onlineMembers = new ArrayList<>();
for (L2ClanMember temp : _members.values())
{
if ((temp != null) && temp.isOnline() && (temp.getObjectId() != exclude))
@@ -1596,59 +1599,32 @@ public class L2Clan implements IIdentifiable, INamable
public boolean isAtWarWith(Integer id)
{
if (!_atWarWith.isEmpty())
{
if (_atWarWith.contains(id))
{
return true;
}
}
return false;
return _atWarWith.contains(id);
}
public boolean isAtWarWith(L2Clan clan)
{
if (clan == null)
{
return false;
}
if (!_atWarWith.isEmpty())
{
if (_atWarWith.contains(clan.getId()))
{
return true;
}
}
return false;
return _atWarWith.contains(clan.getId());
}
public boolean isAtWarAttacker(Integer id)
public boolean isAtWarAttacker(int id)
{
if ((_atWarAttackers != null) && !_atWarAttackers.isEmpty())
{
if (_atWarAttackers.contains(id))
{
return true;
}
}
return false;
return _atWarAttackers.contains(id);
}
public void setEnemyClan(L2Clan clan)
{
Integer id = clan.getId();
_atWarWith.add(id);
_atWarWith.add(clan.getId());
}
public void setEnemyClan(Integer clan)
public void setEnemyClan(int id)
{
_atWarWith.add(clan);
_atWarWith.add(id);
}
public void setAttackerClan(L2Clan clan)
{
Integer id = clan.getId();
_atWarAttackers.add(id);
_atWarAttackers.add(clan.getId());
}
public void setAttackerClan(Integer clan)
@@ -1658,14 +1634,12 @@ public class L2Clan implements IIdentifiable, INamable
public void deleteEnemyClan(L2Clan clan)
{
Integer id = clan.getId();
_atWarWith.remove(id);
_atWarWith.remove(clan.getId());
}
public void deleteAttackerClan(L2Clan clan)
{
Integer id = clan.getId();
_atWarAttackers.remove(id);
_atWarAttackers.remove(clan.getId());
}
public int getHiredGuards()
@@ -1680,11 +1654,7 @@ public class L2Clan implements IIdentifiable, INamable
public boolean isAtWar()
{
if ((_atWarWith != null) && !_atWarWith.isEmpty())
{
return true;
}
return false;
return (_atWarWith != null) && !_atWarWith.isEmpty();
}
public List<Integer> getWarList()
@@ -1871,11 +1841,6 @@ public class L2Clan implements IIdentifiable, INamable
*/
public final SubPledge[] getAllSubPledges()
{
if (_subPledges == null)
{
return new SubPledge[0];
}
return _subPledges.values().toArray(new SubPledge[_subPledges.values().size()]);
}
@@ -2036,11 +2001,9 @@ public class L2Clan implements IIdentifiable, INamable
public void initializePrivs()
{
RankPrivs privs;
for (int i = 1; i < 10; i++)
{
privs = new RankPrivs(i, 0, new EnumIntBitmask<>(ClanPrivilege.class, false));
_privs.put(i, privs);
_privs.put(i, new RankPrivs(i, 0, new EnumIntBitmask<>(ClanPrivilege.class, false)));
}
}
@@ -2988,9 +2951,9 @@ public class L2Clan implements IIdentifiable, INamable
return false;
}
public SubPledgeSkill[] getAllSubSkills()
public List<SubPledgeSkill> getAllSubSkills()
{
final ArrayList<SubPledgeSkill> list = new ArrayList<>();
final List<SubPledgeSkill> list = new LinkedList<>();
for (Skill skill : _subPledgeSkills.values())
{
list.add(new SubPledgeSkill(0, skill.getId(), skill.getLevel()));
@@ -3002,7 +2965,7 @@ public class L2Clan implements IIdentifiable, INamable
list.add(new SubPledgeSkill(subunit.getId(), skill.getId(), skill.getLevel()));
}
}
return list.toArray(new SubPledgeSkill[list.size()]);
return list;
}
public void setNewLeaderId(int objectId, boolean storeInDb)

View File

@@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.model;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Function;
@@ -37,8 +38,8 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
*/
public class L2CommandChannel extends AbstractPlayerGroup
{
private final List<L2Party> _parties;
private L2PcInstance _commandLeader = null;
private final List<L2Party> _parties = new CopyOnWriteArrayList<>();
private L2PcInstance _commandLeader;
private int _channelLvl;
/**
@@ -49,7 +50,6 @@ public class L2CommandChannel extends AbstractPlayerGroup
{
_commandLeader = leader;
L2Party party = leader.getParty();
_parties = new CopyOnWriteArrayList<>();
_parties.add(party);
_channelLvl = party.getLevel();
party.setCommandChannel(this);
@@ -163,7 +163,7 @@ public class L2CommandChannel extends AbstractPlayerGroup
@Override
public List<L2PcInstance> getMembers()
{
List<L2PcInstance> members = new CopyOnWriteArrayList<>();
final List<L2PcInstance> members = new LinkedList<>();
for (L2Party party : getPartys())
{
members.addAll(party.getMembers());

View File

@@ -43,7 +43,7 @@ public class L2ContactList
{
private final Logger _log = Logger.getLogger(getClass().getName());
private final L2PcInstance activeChar;
private final List<String> _contacts;
private final List<String> _contacts = new CopyOnWriteArrayList<>();
private static final String QUERY_ADD = "INSERT INTO character_contacts (charId, contactId) VALUES (?, ?)";
private static final String QUERY_REMOVE = "DELETE FROM character_contacts WHERE charId = ? and contactId = ?";
@@ -52,7 +52,6 @@ public class L2ContactList
public L2ContactList(L2PcInstance player)
{
activeChar = player;
_contacts = new CopyOnWriteArrayList<>();
restore();
}

View File

@@ -525,7 +525,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
{
if (_scripts == null)
{
// Double-checked locking
synchronized (this)
{
if (_scripts == null)

View File

@@ -21,9 +21,9 @@ package com.l2jserver.gameserver.model;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -83,7 +83,7 @@ public class L2Party extends AbstractPlayerGroup
private static final Duration PARTY_POSITION_BROADCAST_INTERVAL = Duration.ofSeconds(12);
private static final Duration PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT = Duration.ofSeconds(15);
private final List<L2PcInstance> _members;
private final List<L2PcInstance> _members = new CopyOnWriteArrayList<>();
private boolean _pendingInvitation = false;
private long _pendingInviteTimeout;
private int _partyLvl = 0;
@@ -116,7 +116,6 @@ public class L2Party extends AbstractPlayerGroup
*/
public L2Party(L2PcInstance leader, PartyDistributionType partyDistributionType)
{
_members = new CopyOnWriteArrayList<>();
_members.add(leader);
_partyLvl = leader.getLevel();
_distributionType = partyDistributionType;
@@ -768,33 +767,26 @@ public class L2Party extends AbstractPlayerGroup
*/
public void distributeAdena(L2PcInstance player, long adena, L2Character target)
{
// Get all the party members
final List<L2PcInstance> membersList = getMembers();
// Check the number of party members that must be rewarded
// (The party member must be in range to receive its reward)
final List<L2PcInstance> ToReward = new ArrayList<>();
for (L2PcInstance member : membersList)
final List<L2PcInstance> toReward = new LinkedList<>();
for (L2PcInstance member : getMembers())
{
if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE2, target, member, true))
if (Util.checkIfInRange(Config.ALT_PARTY_RANGE2, target, member, true))
{
continue;
toReward.add(member);
}
ToReward.add(member);
}
// Avoid null exceptions, if any
if (ToReward.isEmpty())
if (!toReward.isEmpty())
{
return;
}
// Now we can actually distribute the adena reward
// (Total adena splitted by the number of party members that are in range and must be rewarded)
final long count = adena / ToReward.size();
for (L2PcInstance member : ToReward)
{
member.addAdena("Party", count, player, true);
// Now we can actually distribute the adena reward
// (Total adena splitted by the number of party members that are in range and must be rewarded)
long count = adena / toReward.size();
for (L2PcInstance member : toReward)
{
member.addAdena("Party", count, player, true);
}
}
}
@@ -1044,14 +1036,7 @@ public class L2Party extends AbstractPlayerGroup
@Override
public L2PcInstance getLeader()
{
try
{
return _members.get(0);
}
catch (NoSuchElementException e)
{
return null;
}
return _members.get(0);
}
public synchronized void requestLootChange(PartyDistributionType partyDistributionType)

View File

@@ -18,7 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.RadarControl;
@@ -29,12 +30,11 @@ import com.l2jserver.gameserver.network.serverpackets.RadarControl;
public final class L2Radar
{
private final L2PcInstance _player;
private final ArrayList<RadarMarker> _markers;
private final List<RadarMarker> _markers = new CopyOnWriteArrayList<>();
public L2Radar(L2PcInstance player)
{
_player = player;
_markers = new ArrayList<>();
}
// Add a marker to player's radar

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.enums.SiegeClanType;
import com.l2jserver.gameserver.model.actor.L2Npc;
@@ -27,8 +27,7 @@ import com.l2jserver.gameserver.model.actor.L2Npc;
public class L2SiegeClan
{
private int _clanId = 0;
private List<L2Npc> _flag = new ArrayList<>();
private int _numFlagsAdded = 0;
private final List<L2Npc> _flag = new CopyOnWriteArrayList<>();
private SiegeClanType _type;
public L2SiegeClan(int clanId, SiegeClanType type)
@@ -39,43 +38,25 @@ public class L2SiegeClan
public int getNumFlags()
{
return _numFlagsAdded;
return _flag.size();
}
public void addFlag(L2Npc flag)
{
_numFlagsAdded++;
getFlag().add(flag);
_flag.add(flag);
}
public boolean removeFlag(L2Npc flag)
{
if (flag == null)
{
return false;
}
boolean ret = getFlag().remove(flag);
// check if null objects or duplicates remain in the list.
// for some reason, this might be happening sometimes...
// delete false duplicates: if this flag got deleted, delete its copies too.
if (ret)
{
while (getFlag().remove(flag))
{
//
}
}
boolean ret = _flag.remove(flag);
flag.deleteMe();
_numFlagsAdded--;
return ret;
}
public void removeFlags()
{
for (L2Npc flag : getFlag())
{
removeFlag(flag);
}
_flag.forEach(f -> f.decayMe());
_flag.clear();
}
public final int getClanId()
@@ -85,10 +66,6 @@ public class L2SiegeClan
public final List<L2Npc> getFlag()
{
if (_flag == null)
{
_flag = new ArrayList<>();
}
return _flag;
}

View File

@@ -19,10 +19,12 @@
package com.l2jserver.gameserver.model;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -79,9 +81,8 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
private boolean _doRespawn;
/** If true then spawn is custom */
private boolean _customSpawn;
private static List<SpawnListener> _spawnListeners = new ArrayList<>();
private final ArrayList<L2Npc> _spawnedNpcs = new ArrayList<>();
private L2Npc _lastSpawn;
private static List<SpawnListener> _spawnListeners = new CopyOnWriteArrayList<>();
private final Deque<L2Npc> _spawnedNpcs = new ConcurrentLinkedDeque<>();
private Map<Integer, Location> _lastSpawnPoints;
private boolean _isNoRndWalk = false; // Is no random walk
@@ -688,7 +689,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
notifyNpcSpawned(mob);
_spawnedNpcs.add(mob);
_lastSpawn = mob;
if (_lastSpawnPoints != null)
{
_lastSpawnPoints.put(mob.getObjectId(), new Location(newlocx, newlocy, newlocz));
@@ -705,28 +705,19 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
public static void addSpawnListener(SpawnListener listener)
{
synchronized (_spawnListeners)
{
_spawnListeners.add(listener);
}
_spawnListeners.add(listener);
}
public static void removeSpawnListener(SpawnListener listener)
{
synchronized (_spawnListeners)
{
_spawnListeners.remove(listener);
}
_spawnListeners.remove(listener);
}
public static void notifyNpcSpawned(L2Npc npc)
{
synchronized (_spawnListeners)
for (SpawnListener listener : _spawnListeners)
{
for (SpawnListener listener : _spawnListeners)
{
listener.npcSpawned(npc);
}
listener.npcSpawned(npc);
}
}
@@ -791,10 +782,10 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
public L2Npc getLastSpawn()
{
return _lastSpawn;
return _spawnedNpcs.peekLast();
}
public final ArrayList<L2Npc> getSpawnedNpcs()
public final Deque<L2Npc> getSpawnedNpcs()
{
return _spawnedNpcs;
}

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import com.l2jserver.util.Rnd;
@@ -46,7 +46,7 @@ public class L2Territory
}
}
private final List<Point> _points;
private final List<Point> _points = new CopyOnWriteArrayList<>();
private final int _terr;
private int _xMin;
private int _xMax;
@@ -58,7 +58,6 @@ public class L2Territory
public L2Territory(int terr)
{
_points = new ArrayList<>();
_terr = terr;
_xMin = 999999;
_xMax = -999999;
@@ -99,14 +98,6 @@ public class L2Territory
_procMax += proc;
}
public void print()
{
for (Point p : _points)
{
_log.info("(" + p._x + "," + p._y + ")");
}
}
public boolean isIntersect(int x, int y, Point p1, Point p2)
{
double dy1 = p1._y - y;

View File

@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -446,15 +447,12 @@ public final class L2World
return null;
}
// Create an ArrayList in order to contain all visible L2Object
List<L2Object> result = new ArrayList<>();
// Go through the ArrayList of region
// Create a list in order to contain all visible objects.
final List<L2Object> result = new LinkedList<>();
for (L2WorldRegion regi : reg.getSurroundingRegions())
{
// Go through visible objects of the selected region
Collection<L2Object> vObj = regi.getVisibleObjects().values();
for (L2Object _object : vObj)
for (L2Object _object : regi.getVisibleObjects().values())
{
if ((_object == null) || _object.equals(object))
{
@@ -488,15 +486,12 @@ public final class L2World
final int sqRadius = radius * radius;
// Create an ArrayList in order to contain all visible L2Object
List<L2Object> result = new ArrayList<>();
// Go through the ArrayList of region
// Create a list in order to contain all visible objects.
final List<L2Object> result = new LinkedList<>();
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
{
// Go through visible objects of the selected region
Collection<L2Object> vObj = regi.getVisibleObjects().values();
for (L2Object _object : vObj)
for (L2Object _object : regi.getVisibleObjects().values())
{
if ((_object == null) || _object.equals(object))
{
@@ -529,14 +524,11 @@ public final class L2World
final int sqRadius = radius * radius;
// Create an ArrayList in order to contain all visible L2Object
List<L2Object> result = new ArrayList<>();
// Go through visible object of the selected region
// Create a list in order to contain all visible objects.
final List<L2Object> result = new LinkedList<>();
for (L2WorldRegion regi : object.getWorldRegion().getSurroundingRegions())
{
Collection<L2Object> vObj = regi.getVisibleObjects().values();
for (L2Object _object : vObj)
for (L2Object _object : regi.getVisibleObjects().values())
{
if ((_object == null) || _object.equals(object))
{
@@ -567,10 +559,8 @@ public final class L2World
return null;
}
// Create an ArrayList in order to contain all visible L2Object
List<L2Playable> result = new ArrayList<>();
// Go through the ArrayList of region
// Create a list in order to contain all visible objects.
final List<L2Playable> result = new LinkedList<>();
for (L2WorldRegion regi : reg.getSurroundingRegions())
{
// Create an Iterator to go through the visible L2Object of the L2WorldRegion

View File

@@ -18,11 +18,12 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
@@ -43,29 +44,24 @@ public final class L2WorldRegion
private static final Logger _log = Logger.getLogger(L2WorldRegion.class.getName());
/** Map containing all playable characters in game in this world region. */
private final Map<Integer, L2Playable> _allPlayable;
private final Map<Integer, L2Playable> _allPlayable = new ConcurrentHashMap<>();
/** Map containing visible objects in this world region. */
private final Map<Integer, L2Object> _visibleObjects;
private final Map<Integer, L2Object> _visibleObjects = new ConcurrentHashMap<>();
private final List<L2WorldRegion> _surroundingRegions;
private final Queue<L2WorldRegion> _surroundingRegions = new ConcurrentLinkedQueue<>();
private final int _tileX, _tileY;
private boolean _active = false;
private ScheduledFuture<?> _neighborsTask = null;
private final List<L2ZoneType> _zones;
private final List<L2ZoneType> _zones = new CopyOnWriteArrayList<>();
public L2WorldRegion(int pTileX, int pTileY)
{
_allPlayable = new ConcurrentHashMap<>();
_visibleObjects = new ConcurrentHashMap<>();
_surroundingRegions = new ArrayList<>();
_tileX = pTileX;
_tileY = pTileY;
// default a newly initialized region to inactive, unless always on is specified
_active = Config.GRIDS_ALWAYS_ON;
_zones = new ArrayList<>();
}
public List<L2ZoneType> getZones()
@@ -233,8 +229,7 @@ public final class L2WorldRegion
int c = 0;
if (!isOn)
{
Collection<L2Object> vObj = _visibleObjects.values();
for (L2Object o : vObj)
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
{
@@ -272,9 +267,7 @@ public final class L2WorldRegion
}
else
{
Collection<L2Object> vObj = _visibleObjects.values();
for (L2Object o : vObj)
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
{
@@ -454,9 +447,9 @@ public final class L2WorldRegion
}
/**
* @return the ArrayList _surroundingRegions containing all L2WorldRegion around the current L2WorldRegion
* @return the list containing all L2WorldRegion around the current world region
*/
public List<L2WorldRegion> getSurroundingRegions()
public Queue<L2WorldRegion> getSurroundingRegions()
{
return _surroundingRegions;
}
@@ -482,8 +475,7 @@ public final class L2WorldRegion
public void deleteVisibleNpcSpawns()
{
_log.fine("Deleting all visible NPC's in Region: " + getName());
Collection<L2Object> vNPC = _visibleObjects.values();
for (L2Object obj : vNPC)
for (L2Object obj : _visibleObjects.values())
{
if (obj instanceof L2Npc)
{

View File

@@ -18,8 +18,9 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.ai.L2ControllableMobAI;
@@ -67,7 +68,7 @@ public final class MobGroup
{
if (_mobs == null)
{
_mobs = new ArrayList<>();
_mobs = new CopyOnWriteArrayList<>();
}
return _mobs;
@@ -369,8 +370,7 @@ public final class MobGroup
protected void removeDead()
{
List<L2ControllableMobInstance> deadMobs = new ArrayList<>();
List<L2ControllableMobInstance> deadMobs = new LinkedList<>();
for (L2ControllableMobInstance mobInst : getMobs())
{
if ((mobInst != null) && mobInst.isDead())

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
@@ -35,7 +35,7 @@ public class MobGroupTable
protected MobGroupTable()
{
_groupMap = new HashMap<>();
_groupMap = new ConcurrentHashMap<>();
}
public static MobGroupTable getInstance()

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
@@ -35,7 +35,7 @@ public class PartyMatchRoomList
protected PartyMatchRoomList()
{
_rooms = new HashMap<>();
_rooms = new ConcurrentHashMap<>();
}
public synchronized void addPartyMatchRoom(int id, PartyMatchRoom room)
@@ -122,4 +122,4 @@ public class PartyMatchRoomList
{
protected static final PartyMatchRoomList _instance = new PartyMatchRoomList();
}
}
}

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -32,7 +32,7 @@ public class PartyMatchWaitingList
protected PartyMatchWaitingList()
{
_members = new ArrayList<>();
_members = new CopyOnWriteArrayList<>();
}
public void addPlayer(L2PcInstance player)

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.enums.PetitionState;
import com.l2jserver.gameserver.enums.PetitionType;
@@ -43,7 +43,7 @@ public final class Petition
private final PetitionType _type;
private PetitionState _state = PetitionState.PENDING;
private final String _content;
private final List<CreatureSay> _messageLog = new ArrayList<>();
private final List<CreatureSay> _messageLog = new CopyOnWriteArrayList<>();
private final L2PcInstance _petitioner;
private L2PcInstance _responder;

View File

@@ -21,7 +21,7 @@ package com.l2jserver.gameserver.model;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -47,7 +47,7 @@ public class StatsSet implements IParserAdvUtils
public StatsSet()
{
this(new HashMap<String, Object>());
this(new LinkedHashMap<>());
}
public StatsSet(Map<String, Object> map)

View File

@@ -20,9 +20,10 @@ package com.l2jserver.gameserver.model;
import static com.l2jserver.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import com.l2jserver.Config;
@@ -49,7 +50,7 @@ public class TradeList
private final L2PcInstance _owner;
private L2PcInstance _partner;
private final List<TradeItem> _items;
private final List<TradeItem> _items = new CopyOnWriteArrayList<>();
private String _title;
private boolean _packaged;
@@ -58,7 +59,6 @@ public class TradeList
public TradeList(L2PcInstance owner)
{
_items = new ArrayList<>();
_owner = owner;
}
@@ -120,9 +120,9 @@ public class TradeList
* @param inventory
* @return L2ItemInstance : items in inventory
*/
public TradeItem[] getAvailableItems(PcInventory inventory)
public List<TradeItem> getAvailableItems(PcInventory inventory)
{
final ArrayList<TradeItem> list = new ArrayList<>();
final List<TradeItem> list = new LinkedList<>();
for (TradeItem item : _items)
{
int el[] = new int[6];
@@ -134,7 +134,7 @@ public class TradeList
inventory.adjustAvailableItem(item);
list.add(item);
}
return list.toArray(new TradeItem[list.size()]);
return list;
}
/**
@@ -682,7 +682,7 @@ public class TradeList
* @param items
* @return int: result of trading. 0 - ok, 1 - canceled (no adena), 2 - failed (item error)
*/
public synchronized int privateStoreBuy(L2PcInstance player, HashSet<ItemRequest> items)
public synchronized int privateStoreBuy(L2PcInstance player, Set<ItemRequest> items)
{
if (_locked)
{

View File

@@ -109,6 +109,7 @@ public class L2Attackable extends L2Npc
private final Map<Integer, AbsorberInfo> _absorbersList = new ConcurrentHashMap<>();
// Misc
private boolean _mustGiveExpSp;
protected int _onKillDelay = 5000;
/**
* Creates an attackable NPC.
@@ -347,7 +348,7 @@ public class L2Attackable extends L2Npc
if ((killer != null) && killer.isPlayable())
{
// Delayed notification
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(killer.getActingPlayer(), this, killer.isSummon()), this);
EventDispatcher.getInstance().notifyEventAsyncDelayed(new OnAttackableKill(killer.getActingPlayer(), this, killer.isSummon()), this, _onKillDelay);
}
// Notify to minions if there are.
@@ -1547,6 +1548,20 @@ public class L2Attackable extends L2Npc
return _seeded;
}
/**
* Set delay for onKill() call, in ms Default: 5000 ms
* @param delay
*/
public final void setOnKillDelay(int delay)
{
_onKillDelay = delay;
}
public final int getOnKillDelay()
{
return _onKillDelay;
}
/**
* Check if the server allows Random Animation.
*/

View File

@@ -2715,7 +2715,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
if (_attackByList == null)
{
_attackByList = new HashSet<>();
_attackByList = ConcurrentHashMap.newKeySet();
}
}
}
@@ -3178,7 +3178,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public void resetCurrentAbnormalVisualEffects()
{
final Collection<BuffInfo> passives = getEffectList().hasPassives() ? new ArrayList<>(getEffectList().getPassives().values()) : null;
final Collection<BuffInfo> passives = getEffectList().hasPassives() ? new ArrayList<>(getEffectList().getPassives()) : null;
//@formatter:off
final Set<AbnormalVisualEffect> abnormalVisualEffects = Stream.concat(getEffectList().getEffects().stream(), passives != null ? passives.stream() : Stream.empty())
.filter(Objects::nonNull)
@@ -5530,7 +5530,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
int _skiprange = 0;
int _skipgeo = 0;
int _skippeace = 0;
List<L2Character> targetList = new ArrayList<>(targets.length);
final List<L2Object> targetList = new ArrayList<>();
for (L2Object target : targets)
{
if (target instanceof L2Character)
@@ -5564,7 +5564,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
}
}
targetList.add((L2Character) target);
targetList.add(target);
}
}
if (targetList.isEmpty())

View File

@@ -18,10 +18,9 @@
*/
package com.l2jserver.gameserver.model.actor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import com.l2jserver.Config;
@@ -53,7 +52,7 @@ import com.l2jserver.gameserver.util.Util;
public abstract class L2Vehicle extends L2Character
{
protected int _dockId = 0;
protected final ArrayList<L2PcInstance> _passengers = new ArrayList<>();
protected final List<L2PcInstance> _passengers = new CopyOnWriteArrayList<>();
protected Location _oustLoc = null;
private Runnable _engine = null;
@@ -231,19 +230,8 @@ public abstract class L2Vehicle extends L2Character
public void oustPlayers()
{
L2PcInstance player;
// Use iterator because oustPlayer will try to remove player from _passengers
final Iterator<L2PcInstance> iter = _passengers.iterator();
while (iter.hasNext())
{
player = iter.next();
iter.remove();
if (player != null)
{
oustPlayer(player);
}
}
_passengers.forEach(p -> oustPlayer(p));
_passengers.clear();
}
public void oustPlayer(L2PcInstance player)
@@ -509,6 +497,11 @@ public abstract class L2Vehicle extends L2Character
return false;
}
@Override
public void detachAI()
{
}
@Override
public boolean isVehicle()
{

View File

@@ -22,10 +22,10 @@ import static com.l2jserver.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.Config;
import com.l2jserver.gameserver.enums.InstanceType;
@@ -46,7 +46,7 @@ public final class L2AuctioneerInstance extends L2Npc
private static final int COND_BUSY_BECAUSE_OF_SIEGE = 1;
private static final int COND_REGULAR = 3;
private final Map<Integer, Auction> _pendingAuctions = new HashMap<>();
private final Map<Integer, Auction> _pendingAuctions = new ConcurrentHashMap<>();
public L2AuctioneerInstance(L2NpcTemplate template)
{

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model.actor.instance;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import com.l2jserver.gameserver.enums.InstanceType;
@@ -56,10 +56,6 @@ public class L2ControlTowerInstance extends L2Tower
{
for (L2Spawn spawn : _guards)
{
if (spawn == null)
{
continue;
}
try
{
spawn.stopRespawn();
@@ -89,7 +85,7 @@ public class L2ControlTowerInstance extends L2Tower
{
if (_guards == null)
{
_guards = new ArrayList<>();
_guards = new CopyOnWriteArrayList<>();
}
}
}

View File

@@ -20,6 +20,7 @@ package com.l2jserver.gameserver.model.actor.instance;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.logging.Level;
@@ -574,19 +575,16 @@ public class L2DoorInstance extends L2Character
return getTemplate().getNodeZ() + getTemplate().getHeight();
}
public Collection<L2DefenderInstance> getKnownDefenders()
public List<L2DefenderInstance> getKnownDefenders()
{
ArrayList<L2DefenderInstance> result = new ArrayList<>();
Collection<L2Object> objs = getKnownList().getKnownObjects().values();
for (L2Object obj : objs)
final List<L2DefenderInstance> result = new ArrayList<>();
for (L2Object obj : getKnownList().getKnownObjects().values())
{
if (obj instanceof L2DefenderInstance)
{
result.add((L2DefenderInstance) obj);
}
}
return result;
}

View File

@@ -18,7 +18,7 @@
*/
package com.l2jserver.gameserver.model.actor.instance;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
@@ -127,7 +127,7 @@ public class L2FortCommanderInstance extends L2DefenderInstance
L2Spawn spawn = getSpawn();
if ((spawn != null) && canTalk())
{
ArrayList<FortSiegeSpawn> commanders = FortSiegeManager.getInstance().getCommanderSpawnList(getFort().getResidenceId());
List<FortSiegeSpawn> commanders = FortSiegeManager.getInstance().getCommanderSpawnList(getFort().getResidenceId());
for (FortSiegeSpawn spawn2 : commanders)
{
if (spawn2.getId() == spawn.getId())

View File

@@ -478,7 +478,7 @@ public final class L2PcInstance extends L2Playable
private int _bookmarkslot = 0; // The Teleport Bookmark Slot
private final Map<Integer, TeleportBookmark> _tpbookmarks = new HashMap<>();
private final Map<Integer, TeleportBookmark> _tpbookmarks = new ConcurrentHashMap<>();
private boolean _canFeed;
private boolean _isInSiege;
@@ -519,11 +519,11 @@ public final class L2PcInstance extends L2Playable
private Transform _transformation;
/** The table containing all L2RecipeList of the L2PcInstance */
private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new HashMap<>();
private final Map<Integer, L2RecipeList> _commonRecipeBook = new HashMap<>();
private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new ConcurrentHashMap<>();
private final Map<Integer, L2RecipeList> _commonRecipeBook = new ConcurrentHashMap<>();
/** Premium Items */
private final Map<Integer, L2PremiumItem> _premiumItems = new HashMap<>();
private final Map<Integer, L2PremiumItem> _premiumItems = new ConcurrentHashMap<>();
/** True if the L2PcInstance is sitting */
private boolean _waitTypeSitting;
@@ -581,7 +581,7 @@ public final class L2PcInstance extends L2Playable
private int _questNpcObject = 0;
/** The table containing all Quests began by the L2PcInstance */
private final Map<String, QuestState> _quests = new HashMap<>();
private final Map<String, QuestState> _quests = new ConcurrentHashMap<>();
/** The list containing all shortCuts of this player. */
private final ShortCuts _shortCuts = new ShortCuts(this);
@@ -589,8 +589,8 @@ public final class L2PcInstance extends L2Playable
/** The list containing all macros of this player. */
private final MacroList _macros = new MacroList(this);
private final List<L2PcInstance> _snoopListener = new ArrayList<>();
private final List<L2PcInstance> _snoopedPlayer = new ArrayList<>();
private final Set<L2PcInstance> _snoopListener = ConcurrentHashMap.newKeySet(1);
private final Set<L2PcInstance> _snoopedPlayer = ConcurrentHashMap.newKeySet(1);
// hennas
private final L2Henna[] _henna = new L2Henna[3];
@@ -710,7 +710,7 @@ public final class L2PcInstance extends L2Playable
/** The fists L2Weapon of the L2PcInstance (used when no weapon is equipped) */
private L2Weapon _fistsWeaponItem;
private final Map<Integer, String> _chars = new HashMap<>();
private final Map<Integer, String> _chars = new LinkedHashMap<>();
// private byte _updateKnownCounter = 0;
@@ -733,9 +733,9 @@ public final class L2PcInstance extends L2Playable
protected boolean _inventoryDisable = false;
/** Player's cubics. */
private final Map<Integer, L2CubicInstance> _cubics = new ConcurrentSkipListMap<>();
private final Map<Integer, L2CubicInstance> _cubics = new ConcurrentSkipListMap<>(); // TODO(Zoey76): This should be sorted in insert order.
/** Active shots. */
protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet();
protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet(1);
public final ReentrantLock soulShotLock = new ReentrantLock();
@@ -1535,7 +1535,7 @@ public final class L2PcInstance extends L2Playable
{
if (_notifyQuestOfDeathList == null)
{
_notifyQuestOfDeathList = new ArrayList<>();
_notifyQuestOfDeathList = new CopyOnWriteArrayList<>();
}
}
}
@@ -5924,7 +5924,7 @@ public final class L2PcInstance extends L2Playable
{
if (_tamedBeast == null)
{
_tamedBeast = new ArrayList<>();
_tamedBeast = new CopyOnWriteArrayList<>();
}
_tamedBeast.add(tamedBeast);
}
@@ -6875,8 +6875,7 @@ public final class L2PcInstance extends L2Playable
su.addAttribute(StatusUpdate.KARMA, getKarma());
sendPacket(su);
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
for (L2PcInstance player : getKnownList().getKnownPlayers().values())
{
if ((player == null) || !isVisibleFor(player))
{
@@ -8537,7 +8536,7 @@ public final class L2PcInstance extends L2Playable
}
// is AutoAttackable if both players are in the same duel and the duel is still going on
if (attacker.isPlayer() && (getDuelState() == Duel.DUELSTATE_DUELLING) && (getDuelId() == ((L2PcInstance) attacker).getDuelId()))
if (attacker.isPlayable() && (getDuelState() == Duel.DUELSTATE_DUELLING) && (getDuelId() == attacker.getActingPlayer().getDuelId()))
{
return true;
}
@@ -10491,7 +10490,7 @@ public final class L2PcInstance extends L2Playable
{
if (_subClasses == null)
{
_subClasses = new HashMap<>();
_subClasses = new ConcurrentSkipListMap<>();
}
return _subClasses;
@@ -11229,10 +11228,7 @@ public final class L2PcInstance extends L2Playable
public void addSnooper(L2PcInstance pci)
{
if (!_snoopListener.contains(pci))
{
_snoopListener.add(pci);
}
}
public void removeSnooper(L2PcInstance pci)
@@ -11242,10 +11238,7 @@ public final class L2PcInstance extends L2Playable
public void addSnooped(L2PcInstance pci)
{
if (!_snoopedPlayer.contains(pci))
{
_snoopedPlayer.add(pci);
}
}
public void removeSnooped(L2PcInstance pci)
@@ -13569,9 +13562,7 @@ public final class L2PcInstance extends L2Playable
return (int) time;
}
/**
* list of character friends
*/
/** Friend list. */
private final HashMap<Integer, Friend> _friendList = new HashMap<>();
private final ArrayList<Integer> _updateMemos = new ArrayList<>();

View File

@@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.logging.Level;
@@ -1024,7 +1025,7 @@ public class L2PetInstance extends L2Summon
int buff_index = 0;
final List<Integer> storedSkills = new ArrayList<>();
final List<Integer> storedSkills = new LinkedList<>();
// Store all effect data along with calculated remaining
if (storeEffects)
@@ -1068,11 +1069,7 @@ public class L2PetInstance extends L2Summon
ps2.setInt(5, ++buff_index);
ps2.execute();
if (!SummonEffectsTable.getInstance().getPetEffects().containsKey(getControlObjectId()))
{
SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new ArrayList<SummonEffect>());
}
SummonEffectsTable.getInstance().getPetEffects().putIfAbsent(getControlObjectId(), new ArrayList<>());
SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, info.getTime()));
}
}
@@ -1109,7 +1106,7 @@ public class L2PetInstance extends L2Summon
{
if (!SummonEffectsTable.getInstance().getPetEffects().containsKey(getControlObjectId()))
{
SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new ArrayList<SummonEffect>());
SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new ArrayList<>());
}
SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effectCurTime));

View File

@@ -46,7 +46,6 @@ public class L2RaceManagerInstance extends L2Npc
public static final int LANES = 8;
public static final int WINDOW_START = 0;
// private static List<Race> _history;
private static List<L2RaceManagerInstance> _managers;
protected static int _raceNumber = 4;
@@ -104,7 +103,6 @@ public class L2RaceManagerInstance extends L2Npc
{
_notInitialized = false;
// _history = new ArrayList<>();
_managers = new ArrayList<>();
ThreadPoolManager s = ThreadPoolManager.getInstance();
@@ -128,7 +126,6 @@ public class L2RaceManagerInstance extends L2Npc
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (58 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (59 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THEY_RE_OFF), 9 * MINUTE, 10 * MINUTE);
// */
}
_managers.add(this);
}

View File

@@ -21,11 +21,12 @@ package com.l2jserver.gameserver.model.actor.instance;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -292,7 +293,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
int buff_index = 0;
final List<Integer> storedSkills = new ArrayList<>();
final List<Integer> storedSkills = new LinkedList<>();
// Store all effect data along with calculated remaining
if (storeEffects)
@@ -351,7 +352,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
}
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new ArrayList<SummonEffect>());
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<SummonEffect>());
}
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, info.getTime()));
@@ -407,7 +408,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
}
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new ArrayList<SummonEffect>());
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<SummonEffect>());
}
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effectCurTime));

View File

@@ -20,8 +20,8 @@ package com.l2jserver.gameserver.model.actor.instance;
import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
import com.l2jserver.gameserver.ThreadPoolManager;
@@ -204,7 +204,7 @@ public final class L2TamedBeastInstance extends L2FeedableBeastInstance
{
if (_beastSkills == null)
{
_beastSkills = new ArrayList<>();
_beastSkills = new CopyOnWriteArrayList<>();
}
_beastSkills.add(skill);
}

View File

@@ -21,6 +21,7 @@ package com.l2jserver.gameserver.model.actor.knownlist;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -204,10 +205,9 @@ public class CharKnownList extends ObjectKnownList
return (L2Character) super.getActiveObject();
}
public Collection<L2Character> getKnownCharacters()
public List<L2Character> getKnownCharacters()
{
ArrayList<L2Character> result = new ArrayList<>();
List<L2Character> result = new LinkedList<>();
final Collection<L2Object> objs = getKnownObjects().values();
for (L2Object obj : objs)
{

View File

@@ -19,7 +19,7 @@
package com.l2jserver.gameserver.model.actor.status;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -42,7 +42,7 @@ public class CharStatus
private double _currentMp = 0; // Current MP of the L2Character
/** Array containing all clients that need to be notified about hp/mp updates of the L2Character */
private Set<L2Character> _StatusListener;
private Set<L2Character> _statusListener;
private Future<?> _regTask;
@@ -106,11 +106,11 @@ public class CharStatus
*/
public final Set<L2Character> getStatusListener()
{
if (_StatusListener == null)
if (_statusListener == null)
{
_StatusListener = new CopyOnWriteArraySet<>();
_statusListener = ConcurrentHashMap.newKeySet();
}
return _StatusListener;
return _statusListener;
}
// place holder, only PcStatus has CP

View File

@@ -100,7 +100,7 @@ public final class CubicAction implements Runnable
boolean useCubicCure = false;
if ((_cubic.getId() >= L2CubicInstance.SMART_CUBIC_EVATEMPLAR) && (_cubic.getId() <= L2CubicInstance.SMART_CUBIC_SPECTRALMASTER))
{
for (BuffInfo info : _cubic.getOwner().getEffectList().getDebuffs().values())
for (BuffInfo info : _cubic.getOwner().getEffectList().getDebuffs())
{
if (info.getSkill().canBeDispeled())
{

View File

@@ -25,8 +25,8 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -61,7 +61,7 @@ public class Auction
private long _currentBid = 0;
private long _startingBid = 0;
private final Map<Integer, Bidder> _bidders = new HashMap<>();
private final Map<Integer, Bidder> _bidders = new ConcurrentHashMap<>();
private static final String[] ItemTypeName =
{
@@ -333,7 +333,7 @@ public class Auction
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
if (getBidders().get(bidder.getClanId()) != null)
if (_bidders.get(bidder.getClanId()) != null)
{
try (PreparedStatement statement = con.prepareStatement("UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?"))
{

View File

@@ -18,9 +18,11 @@
*/
package com.l2jserver.gameserver.model.entity;
import java.util.ArrayList;
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.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -61,15 +63,15 @@ public final class BlockCheckerEngine
// The object which holds all basic members info
protected ArenaParticipantsHolder _holder;
// Maps to hold player of each team and his points
protected HashMap<L2PcInstance, Integer> _redTeamPoints = new HashMap<>();
protected HashMap<L2PcInstance, Integer> _blueTeamPoints = new HashMap<>();
protected Map<L2PcInstance, Integer> _redTeamPoints = new ConcurrentHashMap<>();
protected Map<L2PcInstance, Integer> _blueTeamPoints = new ConcurrentHashMap<>();
// The initial points of the event
protected int _redPoints = 15;
protected int _bluePoints = 15;
// Current used arena
protected int _arena = -1;
// All blocks
protected ArrayList<L2Spawn> _spawns = new ArrayList<>();
protected List<L2Spawn> _spawns = new CopyOnWriteArrayList<>();
// Sets if the red team won the event at the end of this (used for packets)
protected boolean _isRedWinner;
// Time when the event starts. Used on packet sending
@@ -118,7 +120,7 @@ public final class BlockCheckerEngine
// Common z coordinate
private static final int _zCoord = -2405;
// List of dropped items in event (for later deletion)
protected ArrayList<L2ItemInstance> _drops = new ArrayList<>();
protected List<L2ItemInstance> _drops = new CopyOnWriteArrayList<>();
// Default arena
private static final byte DEFAULT_ARENA = -1;
// Event is started
@@ -597,12 +599,6 @@ public final class BlockCheckerEngine
for (L2ItemInstance item : _drops)
{
// npe
if (item == null)
{
continue;
}
// a player has it, it will be deleted later
if (!item.isVisible() || (item.getOwnerId() != 0))
{
@@ -651,12 +647,12 @@ public final class BlockCheckerEngine
}
/**
* Reward the speicifed team as a winner team 1) Higher score - 8 extra 2) Higher score - 5 extra
* Reward the specified team as a winner team 1) Higher score - 8 extra 2) Higher score - 5 extra
* @param isRed
*/
private void rewardAsWinner(boolean isRed)
{
HashMap<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
Map<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
// Main give
for (Entry<L2PcInstance, Integer> points : tempPoints.entrySet())
@@ -713,7 +709,7 @@ public final class BlockCheckerEngine
*/
private void rewardAsLooser(boolean isRed)
{
HashMap<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
Map<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
for (Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
{
@@ -726,7 +722,7 @@ public final class BlockCheckerEngine
}
/**
* Telport players back, give status back and send final packet
* Teleport players back, give status back and send final packet
*/
private void setPlayersBack()
{

View File

@@ -23,10 +23,10 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -243,7 +243,7 @@ public final class Castle extends AbstractResidence
{
super(castleId);
load();
_function = new HashMap<>();
_function = new ConcurrentHashMap<>();
initResidenceZone();
spawnSideNpcs();
if (getOwnerId() != 0)
@@ -260,11 +260,7 @@ public final class Castle extends AbstractResidence
*/
public CastleFunction getFunction(int type)
{
if (_function.containsKey(type))
{
return _function.get(type);
}
return null;
return _function.get(type);
}
public synchronized void engrave(L2Clan clan, L2Object target, CastleSide side)

View File

@@ -22,8 +22,8 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -212,7 +212,7 @@ public abstract class ClanHall
_ownerId = set.getInt("ownerId");
_desc = set.getString("desc");
_location = set.getString("location");
_functions = new HashMap<>();
_functions = new ConcurrentHashMap<>();
if (_ownerId > 0)
{
@@ -306,11 +306,7 @@ public abstract class ClanHall
*/
public ClanHallFunction getFunction(int type)
{
if (_functions.get(type) != null)
{
return _functions.get(type);
}
return null;
return _functions.get(type);
}
/**

View File

@@ -18,7 +18,6 @@
*/
package com.l2jserver.gameserver.model.entity;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -108,7 +107,7 @@ public class Duel
private double _cp;
private boolean _paDuel;
private int _x, _y, _z;
private ArrayList<Skill> _debuffs;
private List<Skill> _debuffs;
public PlayerCondition(L2PcInstance player, boolean partyDuel)
{
@@ -160,7 +159,7 @@ public class Duel
{
if (_debuffs == null)
{
_debuffs = new ArrayList<>();
_debuffs = new CopyOnWriteArrayList<>();
}
_debuffs.add(debuff);

View File

@@ -28,6 +28,8 @@ import java.util.HashSet;
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.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
@@ -76,14 +78,14 @@ public final class Fort extends AbstractResidence
private int _state = 0;
private int _castleId = 0;
private int _supplyLvL = 0;
private final HashMap<Integer, FortFunction> _function;
private final Map<Integer, FortFunction> _function;
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
// Spawn Data
private boolean _isSuspiciousMerchantSpawned = false;
private final ArrayList<L2Spawn> _siegeNpcs = new ArrayList<>();
private final ArrayList<L2Spawn> _npcCommanders = new ArrayList<>();
private final ArrayList<L2Spawn> _specialEnvoys = new ArrayList<>();
private final List<L2Spawn> _siegeNpcs = new CopyOnWriteArrayList<>();
private final List<L2Spawn> _npcCommanders = new CopyOnWriteArrayList<>();
private final List<L2Spawn> _specialEnvoys = new CopyOnWriteArrayList<>();
private final Map<Integer, Integer> _envoyCastles = new HashMap<>(2);
private final Set<Integer> _availableCastles = new HashSet<>(1);
@@ -242,7 +244,7 @@ public final class Fort extends AbstractResidence
super(fortId);
load();
loadFlagPoles();
_function = new HashMap<>();
_function = new ConcurrentHashMap<>();
if (getOwnerClan() != null)
{
setVisibleFlag(true);
@@ -268,11 +270,7 @@ public final class Fort extends AbstractResidence
*/
public FortFunction getFunction(int type)
{
if (_function.get(type) != null)
{
return _function.get(type);
}
return null;
return _function.get(type);
}
public void endOfSiege(L2Clan clan)

View File

@@ -21,9 +21,10 @@ package com.l2jserver.gameserver.model.entity;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -224,10 +225,10 @@ public class FortSiege implements Siegable
}
}
private final List<L2SiegeClan> _attackerClans = new ArrayList<>();
private final List<L2SiegeClan> _attackerClans = new CopyOnWriteArrayList<>();
// Fort setting
protected ArrayList<L2Spawn> _commanders = new ArrayList<>();
protected List<L2Spawn> _commanders = new CopyOnWriteArrayList<>();
protected final Fort _fort;
private boolean _isInProgress = false;
private FortSiegeGuardManager _siegeGuardManager;
@@ -364,10 +365,7 @@ public class FortSiege implements Siegable
clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
for (L2PcInstance member : clan.getOnlineMembers(0))
{
if (member != null)
{
member.sendPacket(sm);
}
member.sendPacket(sm);
}
}
if (getFort().getOwnerClan() != null)
@@ -397,11 +395,6 @@ public class FortSiege implements Siegable
clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
for (L2PcInstance member : clan.getOnlineMembers(0))
{
if (member == null)
{
continue;
}
if (clear)
{
member.setSiegeState((byte) 0);
@@ -550,18 +543,12 @@ public class FortSiege implements Siegable
@Override
public List<L2PcInstance> getAttackersInZone()
{
List<L2PcInstance> players = new ArrayList<>();
L2Clan clan;
final List<L2PcInstance> players = new LinkedList<>();
for (L2SiegeClan siegeclan : getAttackerClans())
{
clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
L2Clan clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
for (L2PcInstance player : clan.getOnlineMembers(0))
{
if (player == null)
{
continue;
}
if (player.isInSiege())
{
players.add(player);
@@ -584,11 +571,10 @@ public class FortSiege implements Siegable
*/
public List<L2PcInstance> getOwnersInZone()
{
List<L2PcInstance> players = new ArrayList<>();
L2Clan clan;
final List<L2PcInstance> players = new LinkedList<>();
if (getFort().getOwnerClan() != null)
{
clan = ClanTable.getInstance().getClan(getFort().getOwnerClan().getId());
L2Clan clan = ClanTable.getInstance().getClan(getFort().getOwnerClan().getId());
if (clan != getFort().getOwnerClan())
{
return null;
@@ -596,11 +582,6 @@ public class FortSiege implements Siegable
for (L2PcInstance player : clan.getOnlineMembers(0))
{
if (player == null)
{
continue;
}
if (player.isInSiege())
{
players.add(player);
@@ -617,12 +598,12 @@ public class FortSiege implements Siegable
*/
public void killedCommander(L2FortCommanderInstance instance)
{
if ((_commanders != null) && (getFort() != null) && (_commanders.size() != 0))
if (!_commanders.isEmpty() && (getFort() != null))
{
L2Spawn spawn = instance.getSpawn();
if (spawn != null)
{
ArrayList<FortSiegeSpawn> commanders = FortSiegeManager.getInstance().getCommanderSpawnList(getFort().getResidenceId());
List<FortSiegeSpawn> commanders = FortSiegeManager.getInstance().getCommanderSpawnList(getFort().getResidenceId());
for (FortSiegeSpawn spawn2 : commanders)
{
if (spawn2.getId() == spawn.getId())

View File

@@ -28,11 +28,10 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import com.l2jserver.Config;
@@ -76,14 +75,14 @@ public class Hero
// delete hero items
private static final String DELETE_ITEMS = "DELETE FROM items WHERE item_id IN (6842, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6618, 6619, 6620, 6621, 9388, 9389, 9390) AND owner_id NOT IN (SELECT charId FROM characters WHERE accesslevel > 0)";
private static final Map<Integer, StatsSet> _heroes = new HashMap<>();
private static final Map<Integer, StatsSet> _completeHeroes = new HashMap<>();
private static final Map<Integer, StatsSet> HEROES = new ConcurrentHashMap<>();
private static final Map<Integer, StatsSet> COMPLETE_HEROS = new ConcurrentHashMap<>();
private static final Map<Integer, StatsSet> _herocounts = new HashMap<>();
private static final Map<Integer, List<StatsSet>> _herofights = new HashMap<>();
private static final Map<Integer, StatsSet> HERO_COUNTS = new ConcurrentHashMap<>();
private static final Map<Integer, List<StatsSet>> HERO_FIGHTS = new ConcurrentHashMap<>();
private static final Map<Integer, List<StatsSet>> _herodiary = new HashMap<>();
private static final Map<Integer, String> _heroMessage = new HashMap<>();
private static final Map<Integer, List<StatsSet>> HERO_DIARY = new ConcurrentHashMap<>();
private static final Map<Integer, String> HERO_MESSAGE = new ConcurrentHashMap<>();
public static final String COUNT = "count";
public static final String PLAYED = "played";
@@ -97,11 +96,6 @@ public class Hero
public static final int ACTION_HERO_GAINED = 2;
public static final int ACTION_CASTLE_TAKEN = 3;
public static Hero getInstance()
{
return SingletonHolder._instance;
}
protected Hero()
{
init();
@@ -109,12 +103,12 @@ public class Hero
private void init()
{
_heroes.clear();
_completeHeroes.clear();
_herocounts.clear();
_herofights.clear();
_herodiary.clear();
_heroMessage.clear();
HEROES.clear();
COMPLETE_HEROS.clear();
HERO_COUNTS.clear();
HERO_FIGHTS.clear();
HERO_DIARY.clear();
HERO_MESSAGE.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
Statement s1 = con.createStatement();
@@ -139,7 +133,7 @@ public class Hero
processHeros(ps, charId, hero);
_heroes.put(charId, hero);
HEROES.put(charId, hero);
}
while (rset2.next())
@@ -154,16 +148,16 @@ public class Hero
processHeros(ps, charId, hero);
_completeHeroes.put(charId, hero);
COMPLETE_HEROS.put(charId, hero);
}
}
catch (SQLException e)
{
_log.log(Level.WARNING, "Hero System: Couldnt load Heroes", e);
_log.warning("Hero System: Couldnt load Heroes: " + e.getMessage());
}
_log.info("Hero System: Loaded " + _heroes.size() + " Heroes.");
_log.info("Hero System: Loaded " + _completeHeroes.size() + " all time Heroes.");
_log.info("Hero System: Loaded " + HEROES.size() + " Heroes.");
_log.info("Hero System: Loaded " + COMPLETE_HEROS.size() + " all time Heroes.");
}
private void processHeros(PreparedStatement ps, int charId, StatsSet hero) throws SQLException
@@ -222,19 +216,19 @@ public class Hero
{
if (rset.next())
{
_heroMessage.put(charId, rset.getString("message"));
HERO_MESSAGE.put(charId, rset.getString("message"));
}
}
}
catch (SQLException e)
{
_log.log(Level.WARNING, "Hero System: Couldnt load Hero Message for CharId: " + charId, e);
_log.warning("Hero System: Couldnt load Hero Message for CharId: " + charId + ": " + e.getMessage());
}
}
public void loadDiary(int charId)
{
final List<StatsSet> _diary = new ArrayList<>();
final List<StatsSet> diary = new ArrayList<>();
int diaryentries = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
@@ -273,31 +267,31 @@ public class Hero
_diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
}
}
_diary.add(_diaryentry);
diary.add(_diaryentry);
diaryentries++;
}
}
_herodiary.put(charId, _diary);
HERO_DIARY.put(charId, diary);
_log.info("Hero System: Loaded " + diaryentries + " diary entries for Hero: " + CharNameTable.getInstance().getNameById(charId));
}
catch (SQLException e)
{
_log.log(Level.WARNING, "Hero System: Couldnt load Hero Diary for CharId: " + charId, e);
_log.warning("Hero System: Couldnt load Hero Diary for CharId: " + charId + ": " + e.getMessage());
}
}
public void loadFights(int charId)
{
final List<StatsSet> _fights = new ArrayList<>();
StatsSet _herocountdata = new StatsSet();
Calendar _data = Calendar.getInstance();
_data.set(Calendar.DAY_OF_MONTH, 1);
_data.set(Calendar.HOUR_OF_DAY, 0);
_data.set(Calendar.MINUTE, 0);
_data.set(Calendar.MILLISECOND, 0);
final List<StatsSet> fights = new ArrayList<>();
StatsSet heroCountData = new StatsSet();
Calendar data = Calendar.getInstance();
data.set(Calendar.DAY_OF_MONTH, 1);
data.set(Calendar.HOUR_OF_DAY, 0);
data.set(Calendar.MINUTE, 0);
data.set(Calendar.MILLISECOND, 0);
long from = _data.getTimeInMillis();
long from = data.getTimeInMillis();
int numberoffights = 0;
int _victorys = 0;
int _losses = 0;
@@ -361,7 +355,7 @@ public class Hero
_draws++;
}
_fights.add(fight);
fights.add(fight);
numberoffights++;
}
@@ -397,7 +391,7 @@ public class Hero
_draws++;
}
_fights.add(fight);
fights.add(fight);
numberoffights++;
}
@@ -405,29 +399,29 @@ public class Hero
}
}
_herocountdata.set("victory", _victorys);
_herocountdata.set("draw", _draws);
_herocountdata.set("loss", _losses);
heroCountData.set("victory", _victorys);
heroCountData.set("draw", _draws);
heroCountData.set("loss", _losses);
_herocounts.put(charId, _herocountdata);
_herofights.put(charId, _fights);
HERO_COUNTS.put(charId, heroCountData);
HERO_FIGHTS.put(charId, fights);
_log.info("Hero System: Loaded " + numberoffights + " fights for Hero: " + CharNameTable.getInstance().getNameById(charId));
}
catch (SQLException e)
{
_log.log(Level.WARNING, "Hero System: Couldnt load Hero fights history for CharId: " + charId, e);
_log.warning("Hero System: Couldnt load Hero fights history for CharId: " + charId + ": " + e);
}
}
public Map<Integer, StatsSet> getHeroes()
{
return _heroes;
return HEROES;
}
public int getHeroByClass(int classid)
{
for (Entry<Integer, StatsSet> e : _heroes.entrySet())
for (Entry<Integer, StatsSet> e : HEROES.entrySet())
{
if (e.getValue().getInt(Olympiad.CLASS_ID) == classid)
{
@@ -439,42 +433,42 @@ public class Hero
public void resetData()
{
_herodiary.clear();
_herofights.clear();
_herocounts.clear();
_heroMessage.clear();
HERO_DIARY.clear();
HERO_FIGHTS.clear();
HERO_COUNTS.clear();
HERO_MESSAGE.clear();
}
public void showHeroDiary(L2PcInstance activeChar, int heroclass, int charid, int page)
{
final int perpage = 10;
if (_herodiary.containsKey(charid))
final List<StatsSet> mainList = HERO_DIARY.get(charid);
if (mainList != null)
{
List<StatsSet> _mainlist = _herodiary.get(charid);
final NpcHtmlMessage DiaryReply = new NpcHtmlMessage();
final NpcHtmlMessage diaryReply = new NpcHtmlMessage();
final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herodiary.htm");
if ((htmContent != null) && _heroMessage.containsKey(charid))
final String heroMessage = HERO_MESSAGE.get(charid);
if ((htmContent != null) && (heroMessage != null))
{
DiaryReply.setHtml(htmContent);
DiaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
DiaryReply.replace("%message%", _heroMessage.get(charid));
DiaryReply.disableValidation();
diaryReply.setHtml(htmContent);
diaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
diaryReply.replace("%message%", heroMessage);
diaryReply.disableValidation();
if (!_mainlist.isEmpty())
if (!mainList.isEmpty())
{
final ArrayList<StatsSet> _list = new ArrayList<>();
_list.addAll(_mainlist);
Collections.reverse(_list);
final List<StatsSet> list = new ArrayList<>(mainList);
Collections.reverse(list);
boolean color = true;
final StringBuilder fList = new StringBuilder(500);
int counter = 0;
int breakat = 0;
for (int i = ((page - 1) * perpage); i < _list.size(); i++)
for (int i = ((page - 1) * perpage); i < list.size(); i++)
{
breakat = i;
StatsSet _diaryentry = _list.get(i);
StatsSet diaryEntry = list.get(i);
StringUtil.append(fList, "<tr><td>");
if (color)
{
@@ -484,8 +478,8 @@ public class Hero
{
StringUtil.append(fList, "<table width=270>");
}
StringUtil.append(fList, "<tr><td width=270><font color=\"LEVEL\">" + _diaryentry.getString("date") + ":xx</font></td></tr>");
StringUtil.append(fList, "<tr><td width=270>" + _diaryentry.getString("action") + "</td></tr>");
StringUtil.append(fList, "<tr><td width=270><font color=\"LEVEL\">" + diaryEntry.getString("date") + ":xx</font></td></tr>");
StringUtil.append(fList, "<tr><td width=270>" + diaryEntry.getString("action") + "</td></tr>");
StringUtil.append(fList, "<tr><td>&nbsp;</td></tr></table>");
StringUtil.append(fList, "</td></tr>");
color = !color;
@@ -496,34 +490,34 @@ public class Hero
}
}
if (breakat < (_list.size() - 1))
if (breakat < (list.size() - 1))
{
DiaryReply.replace("%buttprev%", "<button value=\"Prev\" action=\"bypass _diary?class=" + heroclass + "&page=" + (page + 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
diaryReply.replace("%buttprev%", "<button value=\"Prev\" action=\"bypass _diary?class=" + heroclass + "&page=" + (page + 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
}
else
{
DiaryReply.replace("%buttprev%", "");
diaryReply.replace("%buttprev%", "");
}
if (page > 1)
{
DiaryReply.replace("%buttnext%", "<button value=\"Next\" action=\"bypass _diary?class=" + heroclass + "&page=" + (page - 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
diaryReply.replace("%buttnext%", "<button value=\"Next\" action=\"bypass _diary?class=" + heroclass + "&page=" + (page - 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
}
else
{
DiaryReply.replace("%buttnext%", "");
diaryReply.replace("%buttnext%", "");
}
DiaryReply.replace("%list%", fList.toString());
diaryReply.replace("%list%", fList.toString());
}
else
{
DiaryReply.replace("%list%", "");
DiaryReply.replace("%buttprev%", "");
DiaryReply.replace("%buttnext%", "");
diaryReply.replace("%list%", "");
diaryReply.replace("%buttprev%", "");
diaryReply.replace("%buttnext%", "");
}
activeChar.sendPacket(DiaryReply);
activeChar.sendPacket(diaryReply);
}
}
}
@@ -535,10 +529,9 @@ public class Hero
int _loss = 0;
int _draw = 0;
if (_herofights.containsKey(charid))
final List<StatsSet> heroFights = HERO_FIGHTS.get(charid);
if (heroFights != null)
{
List<StatsSet> _list = _herofights.get(charid);
final NpcHtmlMessage FightReply = new NpcHtmlMessage();
final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herohistory.htm");
if (htmContent != null)
@@ -546,24 +539,24 @@ public class Hero
FightReply.setHtml(htmContent);
FightReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
if (!_list.isEmpty())
if (!heroFights.isEmpty())
{
if (_herocounts.containsKey(charid))
final StatsSet heroCount = HERO_COUNTS.get(charid);
if (heroCount != null)
{
StatsSet _herocount = _herocounts.get(charid);
_win = _herocount.getInt("victory");
_loss = _herocount.getInt("loss");
_draw = _herocount.getInt("draw");
_win = heroCount.getInt("victory");
_loss = heroCount.getInt("loss");
_draw = heroCount.getInt("draw");
}
boolean color = true;
final StringBuilder fList = new StringBuilder(500);
int counter = 0;
int breakat = 0;
for (int i = ((page - 1) * perpage); i < _list.size(); i++)
for (int i = ((page - 1) * perpage); i < heroFights.size(); i++)
{
breakat = i;
StatsSet fight = _list.get(i);
StatsSet fight = heroFights.get(i);
StringUtil.append(fList, "<tr><td>");
if (color)
{
@@ -585,7 +578,7 @@ public class Hero
}
}
if (breakat < (_list.size() - 1))
if (breakat < (heroFights.size() - 1))
{
FightReply.replace("%buttprev%", "<button value=\"Prev\" action=\"bypass _match?class=" + heroclass + "&page=" + (page + 1) + "\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
}
@@ -625,7 +618,7 @@ public class Hero
{
updateHeroes(true);
for (Integer objectId : _heroes.keySet())
for (Integer objectId : HEROES.keySet())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if (player == null)
@@ -662,26 +655,27 @@ public class Hero
player.broadcastUserInfo();
}
deleteItemsInDb();
HEROES.clear();
if (newHeroes.isEmpty())
{
_heroes.clear();
return;
}
Map<Integer, StatsSet> heroes = new HashMap<>();
for (StatsSet hero : newHeroes)
{
int charId = hero.getInt(Olympiad.CHAR_ID);
if ((_completeHeroes != null) && _completeHeroes.containsKey(charId))
if (COMPLETE_HEROS.containsKey(charId))
{
StatsSet oldHero = _completeHeroes.get(charId);
StatsSet oldHero = COMPLETE_HEROS.get(charId);
int count = oldHero.getInt(COUNT);
oldHero.set(COUNT, count + 1);
oldHero.set(PLAYED, 1);
oldHero.set(CLAIMED, false);
heroes.put(charId, oldHero);
HEROES.put(charId, oldHero);
}
else
{
@@ -691,17 +685,10 @@ public class Hero
newHero.set(COUNT, 1);
newHero.set(PLAYED, 1);
newHero.set(CLAIMED, false);
heroes.put(charId, newHero);
HEROES.put(charId, newHero);
}
}
deleteItemsInDb();
_heroes.clear();
_heroes.putAll(heroes);
heroes.clear();
updateHeroes(false);
}
@@ -720,11 +707,11 @@ public class Hero
{
StatsSet hero;
int heroId;
for (Entry<Integer, StatsSet> entry : _heroes.entrySet())
for (Entry<Integer, StatsSet> entry : HEROES.entrySet())
{
hero = entry.getValue();
heroId = entry.getKey();
if (_completeHeroes.isEmpty() || !_completeHeroes.containsKey(heroId))
if (!COMPLETE_HEROS.containsKey(heroId))
{
try (PreparedStatement insert = con.prepareStatement(INSERT_HERO))
{
@@ -771,9 +758,9 @@ public class Hero
}
}
}
_heroes.put(heroId, hero);
HEROES.put(heroId, hero);
_completeHeroes.put(heroId, hero);
COMPLETE_HEROS.put(heroId, hero);
}
else
{
@@ -791,7 +778,7 @@ public class Hero
}
catch (SQLException e)
{
_log.log(Level.WARNING, "Hero System: Couldnt update Heroes", e);
_log.warning("Hero System: Couldnt update Heroes: " + e.getMessage());
}
}
@@ -804,23 +791,17 @@ public class Hero
{
setDiaryData(charId, ACTION_RAID_KILLED, npcId);
L2NpcTemplate template = NpcData.getInstance().getTemplate(npcId);
if (_herodiary.containsKey(charId) && (template != null))
final L2NpcTemplate template = NpcData.getInstance().getTemplate(npcId);
final List<StatsSet> list = HERO_DIARY.get(charId);
if ((list != null) && (template != null))
{
// Get Data
List<StatsSet> _list = _herodiary.get(charId);
// Clear old data
_herodiary.remove(charId);
// Prepare new data
StatsSet _diaryentry = new StatsSet();
String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
_diaryentry.set("date", date);
_diaryentry.set("action", template.getName() + " was defeated");
final StatsSet diaryEntry = new StatsSet();
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
diaryEntry.set("date", date);
diaryEntry.set("action", template.getName() + " was defeated");
// Add to old list
_list.add(_diaryentry);
// Put new list into diary
_herodiary.put(charId, _list);
list.add(diaryEntry);
}
}
@@ -828,22 +809,17 @@ public class Hero
{
setDiaryData(charId, ACTION_CASTLE_TAKEN, castleId);
Castle castle = CastleManager.getInstance().getCastleById(castleId);
if ((castle != null) && _herodiary.containsKey(charId))
final Castle castle = CastleManager.getInstance().getCastleById(castleId);
final List<StatsSet> list = HERO_DIARY.get(charId);
if ((list != null) && (castle != null))
{
// Get Data
List<StatsSet> _list = _herodiary.get(charId);
// Clear old data
_herodiary.remove(charId);
// Prepare new data
StatsSet _diaryentry = new StatsSet();
String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
_diaryentry.set("date", date);
_diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
final StatsSet diaryEntry = new StatsSet();
final String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
diaryEntry.set("date", date);
diaryEntry.set("action", castle.getName() + " Castle was successfuly taken");
// Add to old list
_list.add(_diaryentry);
// Put new list into diary
_herodiary.put(charId, _list);
list.add(diaryEntry);
}
}
@@ -860,7 +836,7 @@ public class Hero
}
catch (SQLException e)
{
_log.log(Level.SEVERE, "SQL exception while saving DiaryData.", e);
_log.severe("SQL exception while saving DiaryData: " + e.getMessage());
}
}
@@ -871,7 +847,7 @@ public class Hero
*/
public void setHeroMessage(L2PcInstance player, String message)
{
_heroMessage.put(player.getObjectId(), message);
HERO_MESSAGE.put(player.getObjectId(), message);
}
/**
@@ -880,7 +856,7 @@ public class Hero
*/
public void saveHeroMessage(int charId)
{
if (_heroMessage.get(charId) == null)
if (HERO_MESSAGE.containsKey(charId))
{
return;
}
@@ -888,13 +864,13 @@ public class Hero
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{
statement.setString(1, _heroMessage.get(charId));
statement.setString(1, HERO_MESSAGE.get(charId));
statement.setInt(2, charId);
statement.execute();
}
catch (SQLException e)
{
_log.log(Level.SEVERE, "SQL exception while saving HeroMessage.", e);
_log.severe("SQL exception while saving HeroMessage:" + e.getMessage());
}
}
@@ -907,7 +883,7 @@ public class Hero
}
catch (SQLException e)
{
_log.log(Level.WARNING, "", e);
_log.warning("Heroes: " + e.getMessage());
}
}
@@ -917,10 +893,7 @@ public class Hero
*/
public void shutdown()
{
for (int charId : _heroMessage.keySet())
{
saveHeroMessage(charId);
}
HERO_MESSAGE.keySet().forEach(c -> saveHeroMessage(c));
}
/**
@@ -930,7 +903,7 @@ public class Hero
*/
public boolean isHero(int objectId)
{
return _heroes.containsKey(objectId) && _heroes.get(objectId).getBoolean(CLAIMED);
return HEROES.containsKey(objectId) && HEROES.get(objectId).getBoolean(CLAIMED);
}
/**
@@ -940,7 +913,7 @@ public class Hero
*/
public boolean isUnclaimedHero(int objectId)
{
return _heroes.containsKey(objectId) && !_heroes.get(objectId).getBoolean(CLAIMED);
return HEROES.containsKey(objectId) && !HEROES.get(objectId).getBoolean(CLAIMED);
}
/**
@@ -949,11 +922,11 @@ public class Hero
*/
public void claimHero(L2PcInstance player)
{
StatsSet hero = _heroes.get(player.getObjectId());
StatsSet hero = HEROES.get(player.getObjectId());
if (hero == null)
{
hero = new StatsSet();
_heroes.put(player.getObjectId(), hero);
HEROES.put(player.getObjectId(), hero);
}
hero.set(CLAIMED, true);
@@ -976,13 +949,18 @@ public class Hero
setHeroGained(player.getObjectId());
loadFights(player.getObjectId());
loadDiary(player.getObjectId());
_heroMessage.put(player.getObjectId(), "");
HERO_MESSAGE.put(player.getObjectId(), "");
updateHeroes(false);
}
public static Hero getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final Hero _instance = new Hero();
protected static final Hero INSTANCE = new Hero();
}
}

View File

@@ -52,6 +52,7 @@ import com.l2jserver.gameserver.model.L2WorldRegion;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.TeleportWhereType;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
@@ -99,7 +100,7 @@ public final class Instance
private final List<Integer> _exceptionList = new ArrayList<>();
protected ScheduledFuture<?> _checkTimeUpTask = null;
protected final Map<Integer, ScheduledFuture<?>> _ejectDeadTasks = new HashMap<>();
protected final Map<Integer, ScheduledFuture<?>> _ejectDeadTasks = new ConcurrentHashMap<>();
public Instance(int id)
{
@@ -573,7 +574,7 @@ public final class Instance
List<L2Spawn> manualSpawn = new ArrayList<>();
for (Node d = group.getFirstChild(); d != null; d = d.getNextSibling())
{
int npcId = 0, x = 0, y = 0, z = 0, heading = 0, respawn = 0, respawnRandom = 0;
int npcId = 0, x = 0, y = 0, z = 0, heading = 0, respawn = 0, respawnRandom = 0, delay = -1;
Boolean allowRandomWalk = null;
if ("spawn".equalsIgnoreCase(d.getNodeName()))
{
@@ -584,6 +585,10 @@ public final class Instance
z = Integer.parseInt(d.getAttributes().getNamedItem("z").getNodeValue());
heading = Integer.parseInt(d.getAttributes().getNamedItem("heading").getNodeValue());
respawn = Integer.parseInt(d.getAttributes().getNamedItem("respawn").getNodeValue());
if (d.getAttributes().getNamedItem("onKillDelay") != null)
{
delay = Integer.parseInt(d.getAttributes().getNamedItem("onKillDelay").getNodeValue());
}
if (d.getAttributes().getNamedItem("respawnRandom") != null)
{
respawnRandom = Integer.parseInt(d.getAttributes().getNamedItem("respawnRandom").getNodeValue());
@@ -619,7 +624,11 @@ public final class Instance
}
if (spawnGroup.equals("general"))
{
spawnDat.doSpawn();
L2Npc spawned = spawnDat.doSpawn();
if ((delay >= 0) && (spawned instanceof L2Attackable))
{
((L2Attackable) spawned).setOnKillDelay(delay);
}
}
else
{

View File

@@ -28,6 +28,8 @@ import java.util.LinkedList;
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.Level;
import java.util.logging.Logger;
@@ -47,7 +49,8 @@ import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
/**
* @since $Revision: 1.3.4.1 $ $Date: 2005/03/27 15:29:32 $ This ancient thingie got reworked by Nik at $Date: 2011/05/17 21:51:39 $ Yeah, for 6 years no one bothered reworking this buggy event engine.
* @author Nik
* @Since 2011/05/17 21:51:39
*/
public class L2Event
{
@@ -57,12 +60,11 @@ public class L2Event
public static String _eventCreator = "";
public static String _eventInfo = "";
public static int _teamsNumber = 0;
public static final Map<Integer, String> _teamNames = new HashMap<>();
public static final List<L2PcInstance> _registeredPlayers = new ArrayList<>();
public static final Map<Integer, List<L2PcInstance>> _teams = new HashMap<>();
public static final Map<Integer, String> _teamNames = new ConcurrentHashMap<>();
public static final List<L2PcInstance> _registeredPlayers = new CopyOnWriteArrayList<>();
public static final Map<Integer, List<L2PcInstance>> _teams = new ConcurrentHashMap<>();
public static int _npcId = 0;
// public static final List<L2Npc> _npcs = new ArrayList<L2Npc>();
private static final Map<L2PcInstance, PlayerEventHolder> _connectionLossData = new HashMap<>();
private static final Map<L2PcInstance, PlayerEventHolder> _connectionLossData = new ConcurrentHashMap<>();
public enum EventState
{
@@ -377,7 +379,7 @@ public class L2Event
_eventInfo = br.readLine();
}
List<L2PcInstance> temp = new ArrayList<>();
List<L2PcInstance> temp = new LinkedList<>();
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if (!player.isOnline())
@@ -435,7 +437,7 @@ public class L2Event
// Insert empty lists at _teams.
for (int i = 0; i < _teamsNumber; i++)
{
_teams.put(i + 1, new ArrayList<L2PcInstance>());
_teams.put(i + 1, new CopyOnWriteArrayList<L2PcInstance>());
}
int i = 0;

View File

@@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -220,9 +221,9 @@ public class Siege implements Siegable
}
// must support Concurrent Modifications
private final List<L2SiegeClan> _attackerClans = new ArrayList<>();
private final List<L2SiegeClan> _defenderClans = new ArrayList<>();
private final List<L2SiegeClan> _defenderWaitingClans = new ArrayList<>();
private final List<L2SiegeClan> _attackerClans = new CopyOnWriteArrayList<>();
private final List<L2SiegeClan> _defenderClans = new CopyOnWriteArrayList<>();
private final List<L2SiegeClan> _defenderWaitingClans = new CopyOnWriteArrayList<>();
// Castle setting
private final List<L2ControlTowerInstance> _controlTowers = new ArrayList<>();
@@ -550,10 +551,7 @@ public class Siege implements Siegable
L2Clan clan = ClanTable.getInstance().getClan(siegeClans.getClanId());
for (L2PcInstance member : clan.getOnlineMembers(0))
{
if (member != null)
{
member.sendPacket(message);
}
member.sendPacket(message);
}
}
@@ -586,11 +584,6 @@ public class Siege implements Siegable
clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
for (L2PcInstance member : clan.getOnlineMembers(0))
{
if (member == null)
{
continue;
}
if (clear)
{
member.setSiegeState((byte) 0);
@@ -833,11 +826,6 @@ public class Siege implements Siegable
clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
for (L2PcInstance player : clan.getOnlineMembers(0))
{
if (player == null)
{
continue;
}
if (player.isInSiege())
{
players.add(player);
@@ -871,11 +859,6 @@ public class Siege implements Siegable
}
for (L2PcInstance player : clan.getOnlineMembers(0))
{
if (player == null)
{
continue;
}
if (player.isInSiege())
{
players.add(player);
@@ -1596,41 +1579,35 @@ public class Siege implements Siegable
// Register guard to the closest Control Tower
// When CT dies, so do all the guards that it controls
if (!getSiegeGuardManager().getSiegeGuardSpawn().isEmpty())
for (L2Spawn spawn : getSiegeGuardManager().getSiegeGuardSpawn())
{
L2ControlTowerInstance closestCt;
double distance;
double distanceClosest = 0;
for (L2Spawn spawn : getSiegeGuardManager().getSiegeGuardSpawn())
if (spawn == null)
{
if (spawn == null)
continue;
}
L2ControlTowerInstance closestCt = null;
double distanceClosest = Integer.MAX_VALUE;
for (L2ControlTowerInstance ct : _controlTowers)
{
if (ct == null)
{
continue;
}
closestCt = null;
distanceClosest = Integer.MAX_VALUE;
double distance = ct.calculateDistance(spawn, true, true);
for (L2ControlTowerInstance ct : _controlTowers)
if (distance < distanceClosest)
{
if (ct == null)
{
continue;
}
distance = ct.calculateDistance(spawn, true, true);
if (distance < distanceClosest)
{
closestCt = ct;
distanceClosest = distance;
}
}
if (closestCt != null)
{
closestCt.registerGuard(spawn);
closestCt = ct;
distanceClosest = distance;
}
}
if (closestCt != null)
{
closestCt.registerGuard(spawn);
}
}
}

View File

@@ -89,11 +89,9 @@ public class TvTEvent
/** Instance id<br> */
private static int _TvTEventInstance = 0;
/**
* No instance of this class!<br>
*/
private TvTEvent()
{
// Prevent external initialization.
}
/**
@@ -165,7 +163,7 @@ public class TvTEvent
* Starts the TvTEvent fight<br>
* 1. Set state EventState.STARTING<br>
* 2. Close doors specified in configs<br>
* 3. Abort if not enought participants(return false)<br>
* 3. Abort if not enough participants(return false)<br>
* 4. Set state EventState.STARTED<br>
* 5. Teleport all participants to team spot<br>
* <br>

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model.entity;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -34,8 +34,8 @@ public class TvTEventTeam
private int[] _coordinates = new int[3];
/** The points of the team<br> */
private short _points;
/** Name and instance of all participated players in HashMap<br> */
private Map<Integer, L2PcInstance> _participatedPlayers = new HashMap<>();
/** Name and instance of all participated players in map. */
private final Map<Integer, L2PcInstance> _participatedPlayers = new ConcurrentHashMap<>();
/**
* C'tor initialize the team<br>
@@ -63,10 +63,7 @@ public class TvTEventTeam
return false;
}
synchronized (_participatedPlayers)
{
_participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
}
_participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
return true;
}
@@ -77,10 +74,7 @@ public class TvTEventTeam
*/
public void removePlayer(int playerObjectId)
{
synchronized (_participatedPlayers)
{
_participatedPlayers.remove(playerObjectId);
}
_participatedPlayers.remove(playerObjectId);
}
/**
@@ -97,7 +91,6 @@ public class TvTEventTeam
public void cleanMe()
{
_participatedPlayers.clear();
_participatedPlayers = new HashMap<>();
_points = 0;
}
@@ -108,14 +101,7 @@ public class TvTEventTeam
*/
public boolean containsPlayer(int playerObjectId)
{
boolean containsPlayer;
synchronized (_participatedPlayers)
{
containsPlayer = _participatedPlayers.containsKey(playerObjectId);
}
return containsPlayer;
return _participatedPlayers.containsKey(playerObjectId);
}
/**
@@ -149,20 +135,13 @@ public class TvTEventTeam
}
/**
* Returns name and instance of all participated players in HashMap<br>
* Returns name and instance of all participated players in FastMap<br>
* <br>
* @return Map<String, L2PcInstance>: map of players in this team<br>
*/
public Map<Integer, L2PcInstance> getParticipatedPlayers()
{
Map<Integer, L2PcInstance> participatedPlayers = null;
synchronized (_participatedPlayers)
{
participatedPlayers = _participatedPlayers;
}
return participatedPlayers;
return _participatedPlayers;
}
/**
@@ -172,13 +151,6 @@ public class TvTEventTeam
*/
public int getParticipatedPlayerCount()
{
int participatedPlayerCount;
synchronized (_participatedPlayers)
{
participatedPlayerCount = _participatedPlayers.size();
}
return participatedPlayerCount;
return _participatedPlayers.size();
}
}

View File

@@ -23,9 +23,9 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
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.ScheduledFuture;
import java.util.logging.Logger;
@@ -71,8 +71,8 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
protected final Logger _log;
private final HashMap<Integer, L2SiegeClan> _attackers = new HashMap<>();
private ArrayList<L2Spawn> _guards;
private final Map<Integer, L2SiegeClan> _attackers = new ConcurrentHashMap<>();
private List<L2Spawn> _guards;
public SiegableHall _hall;
public ScheduledFuture<?> _siegeTask;
@@ -91,8 +91,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
loadAttackers();
}
// XXX Load methods -------------------------------
public void loadAttackers()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
@@ -123,11 +121,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
delStatement.setInt(1, _hall.getId());
delStatement.execute();
if (getAttackers().size() > 0)
if (_attackers.size() > 0)
{
try (PreparedStatement insert = con.prepareStatement(SQL_SAVE_ATTACKERS))
{
for (L2SiegeClan clan : getAttackers().values())
for (L2SiegeClan clan : _attackers.values())
{
insert.setInt(1, _hall.getId());
insert.setInt(2, clan.getClanId());
@@ -175,32 +173,24 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
}
}
// XXX Npc Management methods ----------------------------
private final void spawnSiegeGuards()
{
for (L2Spawn guard : _guards)
{
if (guard != null)
{
guard.init();
}
guard.init();
}
}
private final void unSpawnSiegeGuards()
{
if ((_guards != null) && (_guards.size() > 0))
if (_guards != null)
{
for (L2Spawn guard : _guards)
{
if (guard != null)
guard.stopRespawn();
if (guard.getLastSpawn() != null)
{
guard.stopRespawn();
if (guard.getLastSpawn() != null)
{
guard.getLastSpawn().deleteMe();
}
guard.getLastSpawn().deleteMe();
}
}
}
@@ -218,9 +208,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
return result;
}
// XXX Attacker clans management -----------------------------
public final HashMap<Integer, L2SiegeClan> getAttackers()
public final Map<Integer, L2SiegeClan> getAttackers()
{
return _attackers;
}
@@ -257,26 +245,21 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
@Override
public List<L2SiegeClan> getAttackerClans()
{
ArrayList<L2SiegeClan> result = new ArrayList<>();
result.addAll(_attackers.values());
return result;
return new ArrayList<>(_attackers.values());
}
@Override
public List<L2PcInstance> getAttackersInZone()
{
final Collection<L2PcInstance> list = _hall.getSiegeZone().getPlayersInside();
List<L2PcInstance> attackers = new ArrayList<>();
for (L2PcInstance pc : list)
final List<L2PcInstance> attackers = new ArrayList<>();
for (L2PcInstance pc : _hall.getSiegeZone().getPlayersInside())
{
final L2Clan clan = pc.getClan();
if ((clan != null) && getAttackers().containsKey(clan.getId()))
if ((clan != null) && _attackers.containsKey(clan.getId()))
{
attackers.add(pc);
}
}
return attackers;
}
@@ -298,14 +281,12 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
return null;
}
// XXX Siege execution --------------------------
public void prepareOwner()
{
if (_hall.getOwnerId() > 0)
{
final L2SiegeClan clan = new L2SiegeClan(_hall.getOwnerId(), SiegeClanType.ATTACKER);
getAttackers().put(clan.getClanId(), new L2SiegeClan(clan.getClanId(), SiegeClanType.ATTACKER));
_attackers.put(clan.getClanId(), new L2SiegeClan(clan.getClanId(), SiegeClanType.ATTACKER));
}
_hall.free();
@@ -321,10 +302,10 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
@Override
public void startSiege()
{
if ((getAttackers().size() < 1) && (_hall.getId() != 21)) // Fortress of resistance dont have attacker list
if ((_attackers.size() < 1) && (_hall.getId() != 21)) // Fortress of resistance don't have attacker list
{
onSiegeEnds();
getAttackers().clear();
_attackers.clear();
_hall.updateNextSiege();
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new PrepareOwner(), _hall.getSiegeDate().getTimeInMillis());
_hall.updateSiegeStatus(SiegeStatus.WAITING_BATTLE);
@@ -340,7 +321,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
_hall.updateSiegeZone(true);
final byte state = 1;
for (L2SiegeClan sClan : getAttackerClans())
for (L2SiegeClan sClan : _attackers.values())
{
final L2Clan clan = ClanTable.getInstance().getClan(sClan.getClanId());
if (clan == null)
@@ -350,12 +331,9 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
for (L2PcInstance pc : clan.getOnlineMembers(0))
{
if (pc != null)
{
pc.setSiegeState(state);
pc.broadcastUserInfo();
pc.setIsInHideoutSiege(true);
}
pc.setSiegeState(state);
pc.broadcastUserInfo();
pc.setIsInHideoutSiege(true);
}
}
@@ -396,7 +374,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
_hall.banishForeigners();
final byte state = 0;
for (L2SiegeClan sClan : getAttackerClans())
for (L2SiegeClan sClan : _attackers.values())
{
final L2Clan clan = ClanTable.getInstance().getClan(sClan.getClanId());
if (clan == null)
@@ -421,7 +399,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
}
}
getAttackers().clear();
_attackers.clear();
onSiegeEnds();
@@ -454,8 +432,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
return _hall.getSiegeDate();
}
// XXX Fame settings ---------------------------
@Override
public boolean giveFame()
{
@@ -468,8 +444,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
return Config.CHS_FAME_AMOUNT;
}
// XXX Misc methods -----------------------------
@Override
public int getFameFrequency()
{
@@ -489,7 +463,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
}
}
// XXX Siege task and abstract methods -------------------
public Location getInnerSpawnLoc(L2PcInstance player)
{
return null;

View File

@@ -25,13 +25,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
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.CopyOnWriteArraySet;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.logging.Level;
@@ -297,10 +295,7 @@ public abstract class AbstractScript implements INamable
if (!ids.isEmpty())
{
if (!_registeredIds.containsKey(type))
{
_registeredIds.put(type, new CopyOnWriteArraySet<Integer>());
}
_registeredIds.putIfAbsent(type, ConcurrentHashMap.newKeySet(ids.size()));
_registeredIds.get(type).addAll(ids);
}
@@ -1374,10 +1369,7 @@ public abstract class AbstractScript implements INamable
}
}
if (!_registeredIds.containsKey(registerType))
{
_registeredIds.put(registerType, new HashSet<Integer>());
}
_registeredIds.putIfAbsent(registerType, ConcurrentHashMap.newKeySet(1));
_registeredIds.get(registerType).add(id);
}
}
@@ -1489,10 +1481,7 @@ public abstract class AbstractScript implements INamable
}
}
}
if (!_registeredIds.containsKey(registerType))
{
_registeredIds.put(registerType, new HashSet<Integer>());
}
_registeredIds.putIfAbsent(registerType, ConcurrentHashMap.newKeySet(ids.size()));
_registeredIds.get(registerType).addAll(ids);
}
else

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model.holders;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.model.Location;
@@ -50,7 +50,7 @@ public final class PlayerEventHolder
private final int _pkKills;
private final int _karma;
private final List<L2PcInstance> _kills;
private final List<L2PcInstance> _kills = new CopyOnWriteArrayList<>();
private boolean _sitForced;
public PlayerEventHolder(L2PcInstance player)
@@ -68,7 +68,7 @@ public final class PlayerEventHolder
_pvpKills = player.getPvpKills();
_pkKills = player.getPkKills();
_karma = player.getKarma();
_kills = new ArrayList<>();
_sitForced = sitForced;
}

View File

@@ -18,8 +18,8 @@
*/
package com.l2jserver.gameserver.model.instancezone;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
@@ -36,7 +36,7 @@ public class InstanceWorld
{
private int _instanceId;
private int _templateId = -1;
private final List<Integer> _allowed = new ArrayList<>();
private final List<Integer> _allowed = new CopyOnWriteArrayList<>();
private final AtomicInteger _status = new AtomicInteger();
public List<Integer> getAllowed()

View File

@@ -21,7 +21,7 @@ package com.l2jserver.gameserver.model.itemcontainer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
@@ -121,7 +121,7 @@ public abstract class ItemContainer
*/
public List<L2ItemInstance> getItemsByItemId(int itemId)
{
final List<L2ItemInstance> returnList = new ArrayList<>();
final List<L2ItemInstance> returnList = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if ((item != null) && (item.getId() == itemId))

View File

@@ -21,7 +21,7 @@ package com.l2jserver.gameserver.model.itemcontainer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -141,7 +141,7 @@ public class PcInventory extends Inventory
public L2ItemInstance[] getUniqueItems(boolean allowAdena, boolean allowAncientAdena, boolean onlyAvailable)
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if (item == null)
@@ -186,7 +186,7 @@ public class PcInventory extends Inventory
public L2ItemInstance[] getUniqueItemsByEnchantLevel(boolean allowAdena, boolean allowAncientAdena, boolean onlyAvailable)
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if (item == null)
@@ -237,7 +237,7 @@ public class PcInventory extends Inventory
*/
public L2ItemInstance[] getAllItemsByItemId(int itemId, boolean includeEquipped)
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if (item == null)
@@ -272,7 +272,7 @@ public class PcInventory extends Inventory
*/
public L2ItemInstance[] getAllItemsByItemId(int itemId, int enchantment, boolean includeEquipped)
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if (item == null)
@@ -296,7 +296,7 @@ public class PcInventory extends Inventory
*/
public L2ItemInstance[] getAvailableItems(boolean allowAdena, boolean allowNonTradeable, boolean feightable)
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if ((item == null) || !item.isAvailable(getOwner(), allowAdena, allowNonTradeable) || !canManipulateWithItemId(item.getId()))
@@ -324,7 +324,7 @@ public class PcInventory extends Inventory
*/
public L2ItemInstance[] getAugmentedItems()
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if ((item != null) && item.isAugmented())
@@ -341,7 +341,7 @@ public class PcInventory extends Inventory
*/
public L2ItemInstance[] getElementItems()
{
final ArrayList<L2ItemInstance> list = new ArrayList<>();
List<L2ItemInstance> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if ((item != null) && (item.getElementals() != null))
@@ -359,7 +359,7 @@ public class PcInventory extends Inventory
*/
public TradeItem[] getAvailableItems(TradeList tradeList)
{
final ArrayList<TradeItem> list = new ArrayList<>();
List<TradeItem> list = new LinkedList<>();
for (L2ItemInstance item : _items)
{
if ((item != null) && item.isAvailable(getOwner(), false, false))

View File

@@ -178,7 +178,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
_duration = set.getInt("duration", -1);
_time = set.getInt("time", -1);
_autoDestroyTime = set.getInt("auto_destroy_time", -1) * 1000;
_bodyPart = ItemTable._slots.get(set.getString("bodypart", "none"));
_bodyPart = ItemTable.SLOTS.get(set.getString("bodypart", "none"));
_bodyPartName = set.getString("bodypart", "none");
_referencePrice = set.getInt("price", 0);
_crystalType = set.getEnum("crystal_type", CrystalType.class, CrystalType.NONE);

View File

@@ -74,7 +74,7 @@ public class AppearanceStone
addTargetType(targetType);
}
final int bodyPart = ItemTable._slots.get(set.getString("bodyPart", "none"));
final int bodyPart = ItemTable.SLOTS.get(set.getString("bodyPart", "none"));
if (bodyPart != L2Item.SLOT_NONE)
{
addBodyPart(bodyPart);

View File

@@ -19,6 +19,7 @@
package com.l2jserver.gameserver.model.multisell;
import java.util.ArrayList;
import java.util.LinkedList;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -32,8 +33,7 @@ public class PreparedListContainer extends ListContainer
public PreparedListContainer(ListContainer template, boolean inventoryOnly, L2PcInstance player, L2Npc npc)
{
super(template);
super(template.getListId());
setMaintainEnchantment(template.getMaintainEnchantment());
setApplyTaxes(false);
double taxRate = 0;
@@ -64,8 +64,7 @@ public class PreparedListContainer extends ListContainer
items = player.getInventory().getUniqueItems(false, false, false);
}
// size is not known - using ArrayList
_entries = new ArrayList<>();
_entries = new LinkedList<>();
for (L2ItemInstance item : items)
{
// only do the match up on equippable items that are not currently equipped

View File

@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.LogRecord;
@@ -57,9 +58,9 @@ public class Olympiad extends ListenersContainer
protected static final Logger _log = Logger.getLogger(Olympiad.class.getName());
protected static final Logger _logResults = Logger.getLogger("olympiad");
private static final Map<Integer, StatsSet> _nobles = new HashMap<>();
protected static List<StatsSet> _heroesToBe;
private static final Map<Integer, Integer> _noblesRank = new HashMap<>();
private static final Map<Integer, StatsSet> NOBLES = new ConcurrentHashMap<>();
private static final List<StatsSet> HEROS_TO_BE = new ArrayList<>();
private static final Map<Integer, Integer> NOBLES_RANK = new HashMap<>();
public static final String OLYMPIAD_HTML_PATH = "data/html/olympiad/";
private static final String OLYMPIAD_LOAD_DATA = "SELECT current_cycle, period, olympiad_end, validation_end, " + "next_weekly_change FROM olympiad_data WHERE id = 0";
@@ -174,7 +175,7 @@ public class Olympiad extends ListenersContainer
private void load()
{
_nobles.clear();
NOBLES.clear();
boolean loaded = false;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA);
@@ -310,13 +311,13 @@ public class Olympiad extends ListenersContainer
}
}
_log.info("Olympiad System: Loaded " + _nobles.size() + " Nobles");
_log.info("Olympiad System: Loaded " + NOBLES.size() + " Nobles");
}
public void loadNoblesRank()
{
_noblesRank.clear();
NOBLES_RANK.clear();
Map<Integer, Integer> tmpPlace = new HashMap<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS);
@@ -348,23 +349,23 @@ public class Olympiad extends ListenersContainer
{
if (chr.getValue() <= rank1)
{
_noblesRank.put(chr.getKey(), 1);
NOBLES_RANK.put(chr.getKey(), 1);
}
else if (tmpPlace.get(chr.getKey()) <= rank2)
{
_noblesRank.put(chr.getKey(), 2);
NOBLES_RANK.put(chr.getKey(), 2);
}
else if (tmpPlace.get(chr.getKey()) <= rank3)
{
_noblesRank.put(chr.getKey(), 3);
NOBLES_RANK.put(chr.getKey(), 3);
}
else if (tmpPlace.get(chr.getKey()) <= rank4)
{
_noblesRank.put(chr.getKey(), 4);
NOBLES_RANK.put(chr.getKey(), 4);
}
else
{
_noblesRank.put(chr.getKey(), 5);
NOBLES_RANK.put(chr.getKey(), 5);
}
}
}
@@ -386,13 +387,20 @@ public class Olympiad extends ListenersContainer
_scheduledOlympiadEnd.cancel(true);
}
_scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(), getMillisToOlympiadEnd());
_scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(HEROS_TO_BE), getMillisToOlympiadEnd());
updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
{
private final List<StatsSet> _herosToBe;
public OlympiadEndTask(List<StatsSet> herosToBe)
{
_herosToBe = herosToBe;
}
@Override
public void run()
{
@@ -412,7 +420,7 @@ public class Olympiad extends ListenersContainer
_period = 1;
sortHerosToBe();
Hero.getInstance().resetData();
Hero.getInstance().computeNewHeroes(_heroesToBe);
Hero.getInstance().computeNewHeroes(_herosToBe);
saveOlympiadStatus();
updateMonthlyData();
@@ -441,12 +449,12 @@ public class Olympiad extends ListenersContainer
protected static int getNobleCount()
{
return _nobles.size();
return NOBLES.size();
}
protected static StatsSet getNobleStats(int playerId)
{
return _nobles.get(playerId);
return NOBLES.get(playerId);
}
private void updateCompStatus()
@@ -549,7 +557,7 @@ public class Olympiad extends ListenersContainer
_scheduledOlympiadEnd.cancel(true);
}
_scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(), 0);
_scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(HEROS_TO_BE), 0);
}
protected long getMillisToValidationEnd()
@@ -658,7 +666,7 @@ public class Olympiad extends ListenersContainer
}
int currentPoints;
for (StatsSet nobleInfo : _nobles.values())
for (StatsSet nobleInfo : NOBLES.values())
{
currentPoints = nobleInfo.getInt(POINTS);
currentPoints += WEEKLY_POINTS;
@@ -676,7 +684,7 @@ public class Olympiad extends ListenersContainer
return;
}
for (StatsSet nobleInfo : _nobles.values())
for (StatsSet nobleInfo : NOBLES.values())
{
nobleInfo.set(COMP_DONE_WEEK, 0);
nobleInfo.set(COMP_DONE_WEEK_CLASSED, 0);
@@ -705,14 +713,14 @@ public class Olympiad extends ListenersContainer
*/
protected synchronized void saveNobleData()
{
if ((_nobles == null) || _nobles.isEmpty())
if (NOBLES.isEmpty())
{
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
{
StatsSet nobleInfo = entry.getValue();
@@ -844,38 +852,32 @@ public class Olympiad extends ListenersContainer
}
LogRecord record;
if (_nobles != null)
_logResults.info("Noble,charid,classid,compDone,points");
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
{
_logResults.info("Noble,charid,classid,compDone,points");
StatsSet nobleInfo;
for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
StatsSet nobleInfo = entry.getValue();
if (nobleInfo == null)
{
nobleInfo = entry.getValue();
if (nobleInfo == null)
{
continue;
}
int charId = entry.getKey();
int classId = nobleInfo.getInt(CLASS_ID);
String charName = nobleInfo.getString(CHAR_NAME);
int points = nobleInfo.getInt(POINTS);
int compDone = nobleInfo.getInt(COMP_DONE);
record = new LogRecord(Level.INFO, charName);
record.setParameters(new Object[]
{
charId,
classId,
compDone,
points
});
_logResults.log(record);
continue;
}
int charId = entry.getKey();
int classId = nobleInfo.getInt(CLASS_ID);
String charName = nobleInfo.getString(CHAR_NAME);
int points = nobleInfo.getInt(POINTS);
int compDone = nobleInfo.getInt(COMP_DONE);
record = new LogRecord(Level.INFO, charName);
record.setParameters(new Object[]
{
charId,
classId,
compDone,
points
});
_logResults.log(record);
}
_heroesToBe = new ArrayList<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
{
@@ -896,7 +898,7 @@ public class Olympiad extends ListenersContainer
if ((element == 132) || (element == 133)) // Male & Female Soulhounds rank as one hero class
{
hero = _nobles.get(hero.getInt(CHAR_ID));
hero = NOBLES.get(hero.getInt(CHAR_ID));
hero.set(CHAR_ID, rset.getInt(CHAR_ID));
soulHounds.add(hero);
}
@@ -909,7 +911,7 @@ public class Olympiad extends ListenersContainer
hero.getInt(CLASS_ID)
});
_logResults.log(record);
_heroesToBe.add(hero);
HEROS_TO_BE.add(hero);
}
}
}
@@ -936,7 +938,7 @@ public class Olympiad extends ListenersContainer
hero.getInt(CLASS_ID)
});
_logResults.log(record);
_heroesToBe.add(hero);
HEROS_TO_BE.add(hero);
break;
}
case 2:
@@ -994,7 +996,7 @@ public class Olympiad extends ListenersContainer
hero.getInt(CLASS_ID)
});
_logResults.log(record);
_heroesToBe.add(hero);
HEROS_TO_BE.add(hero);
break;
}
}
@@ -1030,24 +1032,24 @@ public class Olympiad extends ListenersContainer
public int getNoblessePasses(L2PcInstance player, boolean clear)
{
if ((player == null) || (_period != 1) || _noblesRank.isEmpty())
if ((player == null) || (_period != 1) || NOBLES_RANK.isEmpty())
{
return 0;
}
final int objId = player.getObjectId();
if (!_noblesRank.containsKey(objId))
if (!NOBLES_RANK.containsKey(objId))
{
return 0;
}
final StatsSet noble = _nobles.get(objId);
final StatsSet noble = NOBLES.get(objId);
if ((noble == null) || (noble.getInt(POINTS) == 0))
{
return 0;
}
final int rank = _noblesRank.get(objId);
final int rank = NOBLES_RANK.get(objId);
int points = (player.isHero() ? Config.ALT_OLY_HERO_POINTS : 0);
switch (rank)
{
@@ -1077,11 +1079,11 @@ public class Olympiad extends ListenersContainer
public int getNoblePoints(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(POINTS);
return NOBLES.get(objId).getInt(POINTS);
}
public int getLastNobleOlympiadPoints(int objId)
@@ -1108,29 +1110,29 @@ public class Olympiad extends ListenersContainer
public int getCompetitionDone(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_DONE);
return NOBLES.get(objId).getInt(COMP_DONE);
}
public int getCompetitionWon(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_WON);
return NOBLES.get(objId).getInt(COMP_WON);
}
public int getCompetitionLost(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_LOST);
return NOBLES.get(objId).getInt(COMP_LOST);
}
/**
@@ -1140,11 +1142,11 @@ public class Olympiad extends ListenersContainer
*/
public int getCompetitionDoneWeek(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_DONE_WEEK);
return NOBLES.get(objId).getInt(COMP_DONE_WEEK);
}
/**
@@ -1154,11 +1156,11 @@ public class Olympiad extends ListenersContainer
*/
public int getCompetitionDoneWeekClassed(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_DONE_WEEK_CLASSED);
return NOBLES.get(objId).getInt(COMP_DONE_WEEK_CLASSED);
}
/**
@@ -1168,11 +1170,11 @@ public class Olympiad extends ListenersContainer
*/
public int getCompetitionDoneWeekNonClassed(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_DONE_WEEK_NON_CLASSED);
return NOBLES.get(objId).getInt(COMP_DONE_WEEK_NON_CLASSED);
}
/**
@@ -1182,11 +1184,11 @@ public class Olympiad extends ListenersContainer
*/
public int getCompetitionDoneWeekTeam(int objId)
{
if ((_nobles == null) || !_nobles.containsKey(objId))
if (!NOBLES.containsKey(objId))
{
return 0;
}
return _nobles.get(objId).getInt(COMP_DONE_WEEK_TEAM);
return NOBLES.get(objId).getInt(COMP_DONE_WEEK_TEAM);
}
/**
@@ -1240,7 +1242,7 @@ public class Olympiad extends ListenersContainer
{
_log.warning("Olympiad System: Couldn't delete nobles from DB!");
}
_nobles.clear();
NOBLES.clear();
}
/**
@@ -1250,7 +1252,7 @@ public class Olympiad extends ListenersContainer
*/
protected static StatsSet addNobleStats(int charId, StatsSet data)
{
return _nobles.put(Integer.valueOf(charId), data);
return NOBLES.put(Integer.valueOf(charId), data);
}
public static Olympiad getInstance()

View File

@@ -80,7 +80,7 @@ public class OlympiadManager
{
if (result == null)
{
result = new ArrayList<>();
result = new CopyOnWriteArrayList<>();
}
result.add(classList.getValue());
@@ -297,7 +297,7 @@ public class OlympiadManager
}
int teamPoints = 0;
ArrayList<Integer> team = new ArrayList<>(party.getMemberCount());
List<Integer> team = new ArrayList<>(party.getMemberCount());
for (L2PcInstance noble : party.getMembers())
{
if (!checkNoble(noble, player))
@@ -391,7 +391,6 @@ public class OlympiadManager
final List<Integer> classed = _classBasedRegisters.get(noble.getBaseClass());
if ((classed != null) && classed.remove(objId))
{
_classBasedRegisters.remove(noble.getBaseClass());
_classBasedRegisters.put(noble.getBaseClass(), classed);
if (Config.L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)

View File

@@ -319,7 +319,7 @@ public final class BuffInfo
if (task != null)
{
task.getScheduledFuture().cancel(true); // Don't allow to finish current run.
_effected.getEffectList().remove(true, this); // Remove the buff from the effect list.
_effected.getEffectList().stopSkillEffects(true, getSkill()); // Remove the buff from the effect list.
}
}
}

View File

@@ -1488,8 +1488,9 @@ public final class Skill implements IIdentifiable
}
default:
{
for (L2Character target : (L2Character[]) targets)
for (L2Object obj : targets)
{
final L2Character target = (L2Character) obj;
if (Formulas.calcBuffDebuffReflection(target, this))
{
// if skill is reflected instant effects should be casted on target

View File

@@ -1511,16 +1511,17 @@ public final class Formulas
{
if (attacker.isPlayer())
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_RESISTED_YOUR_S2);
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.DAMAGE_IS_DECREASED_BECAUSE_C1_RESISTED_C2_S_MAGIC);
sm.addCharName(target);
sm.addSkillName(skill);
sm.addCharName(attacker);
attacker.sendPacket(sm);
damage /= 2;
}
if (target.isPlayer())
{
SystemMessage sm2 = SystemMessage.getSystemMessage(SystemMessageId.YOU_RESISTED_C1_S_MAGIC);
SystemMessage sm2 = SystemMessage.getSystemMessage(SystemMessageId.C1_WEAKLY_RESISTED_C2_S_MAGIC);
sm2.addCharName(target);
sm2.addCharName(attacker);
target.sendPacket(sm2);
}
@@ -1916,14 +1917,14 @@ public final class Formulas
}
// Prevent initialization.
final List<BuffInfo> buffs = target.getEffectList().hasBuffs() ? new ArrayList<>(target.getEffectList().getBuffs().values()) : new ArrayList<>(1);
final List<BuffInfo> buffs = target.getEffectList().hasBuffs() ? new ArrayList<>(target.getEffectList().getBuffs()) : new ArrayList<>(1);
if (target.getEffectList().hasTriggered())
{
buffs.addAll(target.getEffectList().getTriggered().values());
buffs.addAll(target.getEffectList().getTriggered());
}
if (target.getEffectList().hasDances())
{
buffs.addAll(target.getEffectList().getDances().values());
buffs.addAll(target.getEffectList().getDances());
}
for (int i = buffs.size() - 1; i >= 0; i--) // reverse order
{
@@ -1942,7 +1943,7 @@ public final class Formulas
}
case "debuff":
{
final List<BuffInfo> debuffs = new ArrayList<>(target.getEffectList().getDebuffs().values());
final List<BuffInfo> debuffs = new ArrayList<>(target.getEffectList().getDebuffs());
for (int i = debuffs.size() - 1; i >= 0; i--)
{
BuffInfo info = debuffs.get(i);

View File

@@ -18,7 +18,6 @@
*/
package com.l2jserver.gameserver.model.variables;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import com.l2jserver.gameserver.model.StatsSet;
@@ -33,11 +32,6 @@ public abstract class AbstractVariables extends StatsSet implements IRestorable,
{
private final AtomicBoolean _hasChanges = new AtomicBoolean(false);
public AbstractVariables()
{
super(new ConcurrentHashMap<String, Object>());
}
/**
* Overriding following methods to prevent from doing useless database operations if there is no changes since player's login.
*/

View File

@@ -47,7 +47,7 @@ public abstract class L2ZoneType extends ListenersContainer
private final int _id;
protected L2ZoneForm _zone;
protected ConcurrentHashMap<Integer, L2Character> _characterList;
protected Map<Integer, L2Character> _characterList;
/** Parameters to affect specific characters */
private boolean _checkAffected = false;

View File

@@ -18,10 +18,10 @@
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jserver.gameserver.GameServer;
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
@@ -56,13 +56,13 @@ public class L2BossZone extends L2ZoneType
// track the times that players got disconnected. Players are allowed
// to log back into the zone as long as their log-out was within _timeInvade time...
// <player objectId, expiration time in milliseconds>
private final Map<Integer, Long> _playerAllowedReEntryTimes = new HashMap<>();
private final Map<Integer, Long> _playerAllowedReEntryTimes = new ConcurrentHashMap<>();
// track the players admitted to the zone who should be allowed back in
// after reboot/server downtime (outside of their control), within 30 of server restart
private final List<Integer> _playersAllowed = new ArrayList<>();
private final List<Integer> _playersAllowed = new CopyOnWriteArrayList<>();
private final List<L2Character> _raidList = new ArrayList<>();
private final List<L2Character> _raidList = new CopyOnWriteArrayList<>();
protected Settings()
{

View File

@@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@@ -46,7 +47,7 @@ public class L2EffectZone extends L2ZoneType
private int _reuse;
protected boolean _bypassConditions;
private boolean _isShowDangerIcon;
protected volatile ConcurrentHashMap<Integer, Integer> _skills;
protected volatile Map<Integer, Integer> _skills;
public L2EffectZone(int id)
{