Removed all ConcurrentLinkedQueue references.

This commit is contained in:
MobiusDev
2015-12-04 20:48:07 +00:00
parent 63ddbd13f6
commit 624171c088
9 changed files with 177 additions and 158 deletions

View File

@@ -240,7 +240,7 @@ public class AdminBuffs implements IAdminCommandHandler
} }
else else
{ {
effects.addAll(target.getEffectList().getPassives()); effects.addAll(target.getEffectList().getPassives().values());
} }
if ((page > ((effects.size() / PAGE_LIMIT) + 1)) || (page < 1)) if ((page > ((effects.size() / PAGE_LIMIT) + 1)) || (page < 1))

View File

@@ -254,7 +254,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
} }
case WHITELIST: case WHITELIST:
{ {
for (BuffInfo info : player.getEffectList().getBuffs()) for (BuffInfo info : player.getEffectList().getBuffs().values())
{ {
if (!inst.getBuffExceptionList().contains(info.getSkill().getId())) if (!inst.getBuffExceptionList().contains(info.getSkill().getId()))
{ {
@@ -264,7 +264,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
for (L2Summon summon : player.getServitors().values()) for (L2Summon summon : player.getServitors().values())
{ {
for (BuffInfo info : summon.getEffectList().getBuffs()) for (BuffInfo info : summon.getEffectList().getBuffs().values())
{ {
if (!inst.getBuffExceptionList().contains(info.getSkill().getId())) if (!inst.getBuffExceptionList().contains(info.getSkill().getId()))
{ {
@@ -276,7 +276,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
final L2Summon pet = player.getPet(); final L2Summon pet = player.getPet();
if (pet != null) if (pet != null)
{ {
for (BuffInfo info : pet.getEffectList().getBuffs()) for (BuffInfo info : pet.getEffectList().getBuffs().values())
{ {
if (!inst.getBuffExceptionList().contains(info.getSkill().getId())) if (!inst.getBuffExceptionList().contains(info.getSkill().getId()))
{ {
@@ -288,7 +288,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
} }
case BLACKLIST: case BLACKLIST:
{ {
for (BuffInfo info : player.getEffectList().getBuffs()) for (BuffInfo info : player.getEffectList().getBuffs().values())
{ {
if (inst.getBuffExceptionList().contains(info.getSkill().getId())) if (inst.getBuffExceptionList().contains(info.getSkill().getId()))
{ {
@@ -298,7 +298,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
for (L2Summon summon : player.getServitors().values()) for (L2Summon summon : player.getServitors().values())
{ {
for (BuffInfo info : summon.getEffectList().getBuffs()) for (BuffInfo info : summon.getEffectList().getBuffs().values())
{ {
if (inst.getBuffExceptionList().contains(info.getSkill().getId())) if (inst.getBuffExceptionList().contains(info.getSkill().getId()))
{ {
@@ -310,7 +310,7 @@ public abstract class AbstractInstance extends AbstractNpcAI
final L2Summon pet = player.getPet(); final L2Summon pet = player.getPet();
if (pet != null) if (pet != null)
{ {
for (BuffInfo info : pet.getEffectList().getBuffs()) for (BuffInfo info : pet.getEffectList().getBuffs().values())
{ {
if (inst.getBuffExceptionList().contains(info.getSkill().getId())) if (inst.getBuffExceptionList().contains(info.getSkill().getId()))
{ {

View File

@@ -26,9 +26,7 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -554,6 +552,11 @@ public class AutoSpawnHandler
for (L2Npc npcInst : spawnInst.getNPCInstanceList()) for (L2Npc npcInst : spawnInst.getNPCInstanceList())
{ {
if (npcInst == null)
{
continue;
}
npcInst.deleteMe(); npcInst.deleteMe();
SpawnTable.getInstance().deleteSpawn(npcInst.getSpawn(), false); SpawnTable.getInstance().deleteSpawn(npcInst.getSpawn(), false);
spawnInst.removeNpcInstance(npcInst); spawnInst.removeNpcInstance(npcInst);
@@ -589,7 +592,7 @@ public class AutoSpawnHandler
protected int _lastLocIndex = -1; protected int _lastLocIndex = -1;
private final Queue<L2Npc> _npcList = new ConcurrentLinkedQueue<>(); private final List<L2Npc> _npcList = new CopyOnWriteArrayList<>();
private final List<Location> _locList = new CopyOnWriteArrayList<>(); private final List<Location> _locList = new CopyOnWriteArrayList<>();
@@ -662,9 +665,16 @@ public class AutoSpawnHandler
return _locList.toArray(new Location[_locList.size()]); return _locList.toArray(new Location[_locList.size()]);
} }
public Queue<L2Npc> getNPCInstanceList() public L2Npc[] getNPCInstanceList()
{ {
return _npcList; L2Npc[] ret;
synchronized (_npcList)
{
ret = new L2Npc[_npcList.size()];
_npcList.toArray(ret);
}
return ret;
} }
public List<L2Spawn> getSpawns() public List<L2Spawn> getSpawns()

View File

@@ -23,10 +23,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -65,18 +64,18 @@ import com.l2jserver.gameserver.network.serverpackets.ShortBuffStatusUpdate;
public final class CharEffectList public final class CharEffectList
{ {
private static final Logger _log = Logger.getLogger(CharEffectList.class.getName()); private static final Logger _log = Logger.getLogger(CharEffectList.class.getName());
/** Queue containing all effects from buffs for this effect list. */ /** Map containing all effects from buffs for this effect list. */
private volatile Queue<BuffInfo> _buffs; private volatile ConcurrentHashMap<Integer, BuffInfo> _buffs;
/** Queue containing all triggered skills for this effect list. */ /** Map containing all triggered skills for this effect list. */
private volatile Queue<BuffInfo> _triggered; private volatile ConcurrentHashMap<Integer, BuffInfo> _triggered;
/** Queue containing all dances/songs for this effect list. */ /** Map containing all dances/songs for this effect list. */
private volatile Queue<BuffInfo> _dances; private volatile ConcurrentHashMap<Integer, BuffInfo> _dances;
/** Queue containing all toggle for this effect list. */ /** Map containing all toggle for this effect list. */
private volatile Queue<BuffInfo> _toggles; private volatile ConcurrentHashMap<Integer, BuffInfo> _toggles;
/** Queue containing all debuffs for this effect list. */ /** Map containing all debuffs for this effect list. */
private volatile Queue<BuffInfo> _debuffs; private volatile ConcurrentHashMap<Integer, BuffInfo> _debuffs;
/** Queue containing all passives for this effect list. They bypass most of the actions and they are not included in most operations. */ /** Map 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; private volatile ConcurrentHashMap<Integer, BuffInfo> _passives;
/** Map containing the all stacked effect in progress for each abnormal type. */ /** Map containing the all stacked effect in progress for each abnormal type. */
private volatile Map<AbnormalType, BuffInfo> _stackedEffects; private volatile Map<AbnormalType, BuffInfo> _stackedEffects;
/** Set containing all abnormal types that shouldn't be added to this creature effect list. */ /** Set containing all abnormal types that shouldn't be added to this creature effect list. */
@@ -113,7 +112,7 @@ public final class CharEffectList
* Gets buff skills. * Gets buff skills.
* @return the buff skills * @return the buff skills
*/ */
public Queue<BuffInfo> getBuffs() public Map<Integer, BuffInfo> getBuffs()
{ {
if (_buffs == null) if (_buffs == null)
{ {
@@ -121,7 +120,7 @@ public final class CharEffectList
{ {
if (_buffs == null) if (_buffs == null)
{ {
_buffs = new ConcurrentLinkedQueue<>(); _buffs = new ConcurrentHashMap<>();
} }
} }
} }
@@ -132,7 +131,7 @@ public final class CharEffectList
* Gets triggered skill skills. * Gets triggered skill skills.
* @return the triggered skill skills * @return the triggered skill skills
*/ */
public Queue<BuffInfo> getTriggered() public Map<Integer, BuffInfo> getTriggered()
{ {
if (_triggered == null) if (_triggered == null)
{ {
@@ -140,7 +139,7 @@ public final class CharEffectList
{ {
if (_triggered == null) if (_triggered == null)
{ {
_triggered = new ConcurrentLinkedQueue<>(); _triggered = new ConcurrentHashMap<>();
} }
} }
} }
@@ -151,7 +150,7 @@ public final class CharEffectList
* Gets dance/song skills. * Gets dance/song skills.
* @return the dance/song skills * @return the dance/song skills
*/ */
public Queue<BuffInfo> getDances() public Map<Integer, BuffInfo> getDances()
{ {
if (_dances == null) if (_dances == null)
{ {
@@ -159,7 +158,7 @@ public final class CharEffectList
{ {
if (_dances == null) if (_dances == null)
{ {
_dances = new ConcurrentLinkedQueue<>(); _dances = new ConcurrentHashMap<>();
} }
} }
} }
@@ -170,7 +169,7 @@ public final class CharEffectList
* Gets toggle skills. * Gets toggle skills.
* @return the toggle skills * @return the toggle skills
*/ */
public Queue<BuffInfo> getToggles() public Map<Integer, BuffInfo> getToggles()
{ {
if (_toggles == null) if (_toggles == null)
{ {
@@ -178,7 +177,7 @@ public final class CharEffectList
{ {
if (_toggles == null) if (_toggles == null)
{ {
_toggles = new ConcurrentLinkedQueue<>(); _toggles = new ConcurrentHashMap<>();
} }
} }
} }
@@ -189,7 +188,7 @@ public final class CharEffectList
* Gets debuff skills. * Gets debuff skills.
* @return the debuff skills * @return the debuff skills
*/ */
public Queue<BuffInfo> getDebuffs() public Map<Integer, BuffInfo> getDebuffs()
{ {
if (_debuffs == null) if (_debuffs == null)
{ {
@@ -197,7 +196,7 @@ public final class CharEffectList
{ {
if (_debuffs == null) if (_debuffs == null)
{ {
_debuffs = new ConcurrentLinkedQueue<>(); _debuffs = new ConcurrentHashMap<>();
} }
} }
} }
@@ -208,7 +207,7 @@ public final class CharEffectList
* Gets passive skills. * Gets passive skills.
* @return the passive skills * @return the passive skills
*/ */
public Queue<BuffInfo> getPassives() public Map<Integer, BuffInfo> getPassives()
{ {
if (_passives == null) if (_passives == null)
{ {
@@ -216,7 +215,7 @@ public final class CharEffectList
{ {
if (_passives == null) if (_passives == null)
{ {
_passives = new ConcurrentLinkedQueue<>(); _passives = new ConcurrentHashMap<>();
} }
} }
} }
@@ -237,27 +236,27 @@ public final class CharEffectList
final List<BuffInfo> buffs = new ArrayList<>(); final List<BuffInfo> buffs = new ArrayList<>();
if (hasBuffs()) if (hasBuffs())
{ {
buffs.addAll(getBuffs()); buffs.addAll(getBuffs().values());
} }
if (hasTriggered()) if (hasTriggered())
{ {
buffs.addAll(getTriggered()); buffs.addAll(getTriggered().values());
} }
if (hasDances()) if (hasDances())
{ {
buffs.addAll(getDances()); buffs.addAll(getDances().values());
} }
if (hasToggles()) if (hasToggles())
{ {
buffs.addAll(getToggles()); buffs.addAll(getToggles().values());
} }
if (hasDebuffs()) if (hasDebuffs())
{ {
buffs.addAll(getDebuffs()); buffs.addAll(getDebuffs().values());
} }
return buffs; return buffs;
} }
@@ -267,14 +266,14 @@ public final class CharEffectList
* @param skill the skill * @param skill the skill
* @return the effect list * @return the effect list
*/ */
private Queue<BuffInfo> getEffectList(Skill skill) private Map<Integer, BuffInfo> getEffectList(Skill skill)
{ {
if (skill == null) if (skill == null)
{ {
return null; return null;
} }
final Queue<BuffInfo> effects; final Map<Integer, BuffInfo> effects;
if (skill.isPassive()) if (skill.isPassive())
{ {
effects = getPassives(); effects = getPassives();
@@ -313,7 +312,7 @@ public final class CharEffectList
{ {
if (hasBuffs()) if (hasBuffs())
{ {
for (BuffInfo info : getBuffs()) for (BuffInfo info : getBuffs().values())
{ {
if (info != null) if (info != null)
{ {
@@ -330,7 +329,7 @@ public final class CharEffectList
if (hasTriggered()) if (hasTriggered())
{ {
for (BuffInfo info : getTriggered()) for (BuffInfo info : getTriggered().values())
{ {
if (info != null) if (info != null)
{ {
@@ -347,7 +346,7 @@ public final class CharEffectList
if (hasDances()) if (hasDances())
{ {
for (BuffInfo info : getDances()) for (BuffInfo info : getDances().values())
{ {
if (info != null) if (info != null)
{ {
@@ -364,7 +363,7 @@ public final class CharEffectList
if (hasToggles()) if (hasToggles())
{ {
for (BuffInfo info : getToggles()) for (BuffInfo info : getToggles().values())
{ {
if (info != null) if (info != null)
{ {
@@ -381,7 +380,7 @@ public final class CharEffectList
if (hasDebuffs()) if (hasDebuffs())
{ {
for (BuffInfo info : getDebuffs()) for (BuffInfo info : getDebuffs().values())
{ {
if (info != null) if (info != null)
{ {
@@ -418,34 +417,29 @@ public final class CharEffectList
public BuffInfo getBuffInfoBySkillId(int skillId) public BuffInfo getBuffInfoBySkillId(int skillId)
{ {
BuffInfo info = null; BuffInfo info = null;
if (hasBuffs()) if (hasBuffs() && getBuffs().containsKey(skillId))
{ {
info = getBuffs().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); info = getBuffs().get(skillId);
} }
else if (hasTriggered() && getTriggered().containsKey(skillId))
if (hasTriggered() && (info == null))
{ {
info = getTriggered().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); info = getTriggered().get(skillId);
} }
else if (hasDances() && getDances().containsKey(skillId))
if (hasDances() && (info == null))
{ {
info = getDances().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); info = getDances().get(skillId);
} }
else if (hasToggles() && getToggles().containsKey(skillId))
if (hasToggles() && (info == null))
{ {
info = getToggles().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); info = getToggles().get(skillId);
} }
else if (hasDebuffs() && getDebuffs().containsKey(skillId))
if (hasDebuffs() && (info == null))
{ {
info = getDebuffs().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); info = getDebuffs().get(skillId);
} }
else if (hasPassives() && getPassives().containsKey(skillId))
if (hasPassives() && (info == null))
{ {
info = getPassives().stream().filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); info = getPassives().get(skillId);
} }
return info; return info;
} }
@@ -473,7 +467,7 @@ public final class CharEffectList
{ {
if (_blockedBuffSlots == null) if (_blockedBuffSlots == null)
{ {
_blockedBuffSlots = ConcurrentHashMap.newKeySet(blockedBuffSlots.size()); _blockedBuffSlots = new CopyOnWriteArraySet<>();
} }
} }
} }
@@ -545,8 +539,13 @@ public final class CharEffectList
return false; return false;
} }
final Queue<BuffInfo> effects = getEffectList(skill); final Map<Integer, BuffInfo> effects = getEffectList(skill);
for (BuffInfo info : effects) if ((effects == null) || effects.isEmpty())
{
return false;
}
for (BuffInfo info : effects.values())
{ {
if ((info != null) && (info.getSkill().getAbnormalType() == type)) if ((info != null) && (info.getSkill().getAbnormalType() == type))
{ {
@@ -609,7 +608,7 @@ public final class CharEffectList
* @param info the buff info * @param info the buff info
* @param effects the effect list * @param effects the effect list
*/ */
protected void stopAndRemove(BuffInfo info, Queue<BuffInfo> effects) protected void stopAndRemove(BuffInfo info, Map<Integer, BuffInfo> effects)
{ {
stopAndRemove(true, info, effects); stopAndRemove(true, info, effects);
} }
@@ -620,7 +619,7 @@ public final class CharEffectList
* @param info the buff info * @param info the buff info
* @param buffs the buff list * @param buffs the buff list
*/ */
private void stopAndRemove(boolean removed, BuffInfo info, Queue<BuffInfo> buffs) private void stopAndRemove(boolean removed, BuffInfo info, Map<Integer, BuffInfo> buffs)
{ {
if (info == null) if (info == null)
{ {
@@ -628,7 +627,7 @@ public final class CharEffectList
} }
// Removes the buff from the given effect list. // Removes the buff from the given effect list.
buffs.remove(info); buffs.remove(info.getSkill().getId());
// Stop the buff effects. // Stop the buff effects.
info.stopAllEffects(removed); info.stopAllEffects(removed);
// If it's a hidden buff that ends, then decrease hidden buff count. // If it's a hidden buff that ends, then decrease hidden buff count.
@@ -645,7 +644,7 @@ public final class CharEffectList
// If it's an herb that ends, check if there are hidden buffs. // If it's an herb that ends, check if there are hidden buffs.
if (info.getSkill().isAbnormalInstant() && hasBuffs()) if (info.getSkill().isAbnormalInstant() && hasBuffs())
{ {
for (BuffInfo buff : getBuffs()) for (BuffInfo buff : getBuffs().values())
{ {
if ((buff != null) && (buff.getSkill().getAbnormalType() == info.getSkill().getAbnormalType()) && !buff.isInUse()) if ((buff != null) && (buff.getSkill().getAbnormalType() == info.getSkill().getAbnormalType()) && !buff.isInUse())
{ {
@@ -703,31 +702,31 @@ public final class CharEffectList
boolean update = false; boolean update = false;
if (hasBuffs()) if (hasBuffs())
{ {
getBuffs().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getBuffs())); getBuffs().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true; update = true;
} }
if (hasTriggered()) if (hasTriggered())
{ {
getTriggered().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getTriggered())); getTriggered().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true; update = true;
} }
if (hasDebuffs()) if (hasDebuffs())
{ {
getDebuffs().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDebuffs())); getDebuffs().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true; update = true;
} }
if (hasDances()) if (hasDances())
{ {
getDances().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDances())); getDances().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getDances()));
update = true; update = true;
} }
if (hasToggles()) if (hasToggles())
{ {
getToggles().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getToggles())); getToggles().values().stream().filter(info -> !info.getSkill().isStayAfterDeath()).forEach(info -> stopAndRemove(info, getToggles()));
update = true; update = true;
} }
@@ -743,31 +742,31 @@ public final class CharEffectList
boolean update = false; boolean update = false;
if (hasBuffs()) if (hasBuffs())
{ {
getBuffs().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getBuffs())); getBuffs().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true; update = true;
} }
if (hasTriggered()) if (hasTriggered())
{ {
getTriggered().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getTriggered())); getTriggered().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true; update = true;
} }
if (hasDebuffs()) if (hasDebuffs())
{ {
getDebuffs().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDebuffs())); getDebuffs().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true; update = true;
} }
if (hasDances()) if (hasDances())
{ {
getDances().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDances())); getDances().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getDances()));
update = true; update = true;
} }
if (hasToggles()) if (hasToggles())
{ {
getToggles().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getToggles())); getToggles().values().stream().filter(info -> !info.getSkill().isStayOnSubclassChange()).forEach(info -> stopAndRemove(info, getToggles()));
update = true; update = true;
} }
@@ -784,12 +783,12 @@ public final class CharEffectList
{ {
if (hasBuffs()) if (hasBuffs())
{ {
getBuffs().forEach(b -> stopAndRemove(b, getBuffs())); getBuffs().forEach((k, info) -> stopAndRemove(info, getBuffs()));
} }
if (triggered && hasTriggered()) if (triggered && hasTriggered())
{ {
getTriggered().forEach(b -> stopAndRemove(b, getTriggered())); getTriggered().forEach((k, info) -> stopAndRemove(info, getTriggered()));
} }
// Update effect flags and icons. // Update effect flags and icons.
@@ -813,7 +812,7 @@ public final class CharEffectList
{ {
if (hasToggles()) if (hasToggles())
{ {
getToggles().forEach(b -> stopAndRemove(b, getToggles())); getToggles().forEach((k, info) -> stopAndRemove(info, getToggles()));
// Update effect flags and icons. // Update effect flags and icons.
updateEffectList(update); updateEffectList(update);
} }
@@ -827,7 +826,7 @@ public final class CharEffectList
{ {
if (hasDances()) if (hasDances())
{ {
getDances().forEach(b -> stopAndRemove(b, getDances())); getDances().forEach((k, info) -> stopAndRemove(info, getDances()));
// Update effect flags and icons. // Update effect flags and icons.
updateEffectList(update); updateEffectList(update);
} }
@@ -841,7 +840,7 @@ public final class CharEffectList
{ {
if (hasDebuffs()) if (hasDebuffs())
{ {
getDebuffs().forEach(b -> stopAndRemove(b, getDebuffs())); getDebuffs().forEach((k, info) -> stopAndRemove(info, getDebuffs()));
// Update effect flags and icons. // Update effect flags and icons.
updateEffectList(update); updateEffectList(update);
} }
@@ -865,31 +864,31 @@ public final class CharEffectList
if (hasBuffs()) if (hasBuffs())
{ {
getBuffs().stream().filter(Objects::nonNull).forEach(action); getBuffs().values().stream().filter(Objects::nonNull).forEach(action);
update = true; update = true;
} }
if (hasTriggered()) if (hasTriggered())
{ {
getTriggered().stream().filter(Objects::nonNull).forEach(action); getTriggered().values().stream().filter(Objects::nonNull).forEach(action);
update = true; update = true;
} }
if (hasDances()) if (hasDances())
{ {
getDances().stream().filter(Objects::nonNull).forEach(action); getDances().values().stream().filter(Objects::nonNull).forEach(action);
update = true; update = true;
} }
if (hasToggles()) if (hasToggles())
{ {
getToggles().stream().filter(Objects::nonNull).forEach(action); getToggles().values().stream().filter(Objects::nonNull).forEach(action);
update = true; update = true;
} }
if (hasDebuffs()) if (hasDebuffs())
{ {
getDebuffs().stream().filter(Objects::nonNull).forEach(action); getDebuffs().values().stream().filter(Objects::nonNull).forEach(action);
update = true; update = true;
} }
@@ -913,7 +912,7 @@ public final class CharEffectList
final BuffInfo info = getBuffInfoBySkillId(skillId); final BuffInfo info = getBuffInfoBySkillId(skillId);
if (info != null) if (info != null)
{ {
remove(removed, info); stopSkillEffects(removed, info.getSkill());
} }
} }
@@ -930,9 +929,15 @@ public final class CharEffectList
*/ */
public void stopSkillEffects(boolean removed, Skill skill) public void stopSkillEffects(boolean removed, Skill skill)
{ {
if (skill != null) if ((skill == null) || !isAffectedBySkill(skill.getId()))
{ {
stopSkillEffects(removed, skill.getId()); return;
}
final Map<Integer, BuffInfo> effects = getEffectList(skill);
if (effects != null)
{
remove(removed, effects.get(skill.getId()));
} }
} }
@@ -971,31 +976,31 @@ public final class CharEffectList
boolean update = false; boolean update = false;
if (hasBuffs()) if (hasBuffs())
{ {
getBuffs().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getBuffs())); getBuffs().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true; update = true;
} }
if (hasTriggered()) if (hasTriggered())
{ {
getTriggered().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getTriggered())); getTriggered().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true; update = true;
} }
if (hasDebuffs()) if (hasDebuffs())
{ {
getDebuffs().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDebuffs())); getDebuffs().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true; update = true;
} }
if (hasDances()) if (hasDances())
{ {
getDances().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDances())); getDances().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getDances()));
update = true; update = true;
} }
if (hasToggles()) if (hasToggles())
{ {
getToggles().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getToggles())); getToggles().values().stream().filter(info -> info.getSkill().isRemovedOnAnyActionExceptMove()).forEach(info -> stopAndRemove(info, getToggles()));
update = true; update = true;
} }
@@ -1013,25 +1018,25 @@ public final class CharEffectList
{ {
if (hasBuffs()) if (hasBuffs())
{ {
getBuffs().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getBuffs())); getBuffs().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getBuffs()));
update = true; update = true;
} }
if (hasTriggered()) if (hasTriggered())
{ {
getTriggered().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getTriggered())); getTriggered().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getTriggered()));
update = true; update = true;
} }
if (hasDances()) if (hasDances())
{ {
getDances().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDances())); getDances().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDances()));
update = true; update = true;
} }
if (hasToggles()) if (hasToggles())
{ {
getToggles().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getToggles())); getToggles().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getToggles()));
update = true; update = true;
} }
} }
@@ -1040,7 +1045,7 @@ public final class CharEffectList
{ {
if (hasDebuffs()) if (hasDebuffs())
{ {
getDebuffs().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDebuffs())); getDebuffs().values().stream().filter(Objects::nonNull).filter(info -> info.getSkill().isRemovedOnDamage()).forEach(info -> stopAndRemove(info, getDebuffs()));
update = true; update = true;
} }
} }
@@ -1143,7 +1148,7 @@ public final class CharEffectList
boolean update = false; boolean update = false;
if (hasBuffs()) if (hasBuffs())
{ {
for (BuffInfo info : getBuffs()) for (BuffInfo info : getBuffs().values())
{ {
update |= function.apply(info); update |= function.apply(info);
} }
@@ -1151,7 +1156,7 @@ public final class CharEffectList
if (hasTriggered()) if (hasTriggered())
{ {
for (BuffInfo info : getTriggered()) for (BuffInfo info : getTriggered().values())
{ {
update |= function.apply(info); update |= function.apply(info);
} }
@@ -1159,7 +1164,7 @@ public final class CharEffectList
if (dances && hasDances()) if (dances && hasDances())
{ {
for (BuffInfo info : getDances()) for (BuffInfo info : getDances().values())
{ {
update |= function.apply(info); update |= function.apply(info);
} }
@@ -1167,7 +1172,7 @@ public final class CharEffectList
if (hasToggles()) if (hasToggles())
{ {
for (BuffInfo info : getToggles()) for (BuffInfo info : getToggles().values())
{ {
update |= function.apply(info); update |= function.apply(info);
} }
@@ -1175,7 +1180,7 @@ public final class CharEffectList
if (hasDebuffs()) if (hasDebuffs())
{ {
for (BuffInfo info : getDebuffs()) for (BuffInfo info : getDebuffs().values())
{ {
update |= function.apply(info); update |= function.apply(info);
} }
@@ -1191,7 +1196,7 @@ public final class CharEffectList
*/ */
public void remove(boolean removed, BuffInfo info) public void remove(boolean removed, BuffInfo info)
{ {
if (info == null) if ((info == null) || !isAffectedBySkill(info.getSkill().getId()))
{ {
return; return;
} }
@@ -1236,15 +1241,13 @@ public final class CharEffectList
} }
// Puts the effects in the list. // Puts the effects in the list.
getPassives().stream().filter(b -> b.getSkill().getId() == skill.getId()).forEach(b -> final BuffInfo infoToRemove = getPassives().put(skill.getId(), info);
if (infoToRemove != null)
{ {
// Removes the old stats from the creature if the skill was present. // Removes the old stats from the creature if the skill was present.
b.setInUse(false); infoToRemove.setInUse(false);
b.removeStats(); infoToRemove.removeStats();
getPassives().remove(b); }
});
getPassives().add(info);
// Initialize effects. // Initialize effects.
info.initializeEffects(); info.initializeEffects();
@@ -1324,7 +1327,7 @@ public final class CharEffectList
} }
// Select the map that holds the effects related to this skill. // Select the map that holds the effects related to this skill.
final Queue<BuffInfo> effects = getEffectList(skill); final Map<Integer, BuffInfo> effects = getEffectList(skill);
// Remove first buff when buff list is full. // Remove first buff when buff list is full.
if (!skill.isDebuff() && !skill.isToggle() && !skill.is7Signs() && !doesStack(skill)) if (!skill.isDebuff() && !skill.isToggle() && !skill.is7Signs() && !doesStack(skill))
{ {
@@ -1342,7 +1345,7 @@ public final class CharEffectList
buffsToRemove = getBuffCount() - _owner.getStat().getMaxBuffCount(); buffsToRemove = getBuffCount() - _owner.getStat().getMaxBuffCount();
} }
for (BuffInfo bi : effects) for (BuffInfo bi : effects.values())
{ {
if (buffsToRemove < 0) if (buffsToRemove < 0)
{ {
@@ -1367,7 +1370,7 @@ public final class CharEffectList
// After removing old buff (same ID) or stacked buff (same abnormal type), // After removing old buff (same ID) or stacked buff (same abnormal type),
// Add the buff to the end of the effect list. // Add the buff to the end of the effect list.
effects.add(info); effects.put(skill.getId(), info);
// Initialize effects. // Initialize effects.
info.initializeEffects(); info.initializeEffects();
// Update effect flags and icons. // Update effect flags and icons.
@@ -1440,7 +1443,7 @@ public final class CharEffectList
// Buffs. // Buffs.
if (hasBuffs()) if (hasBuffs())
{ {
for (BuffInfo info : getBuffs()) for (BuffInfo info : getBuffs().values())
{ {
if (info.getSkill().isHealingPotionSkill()) if (info.getSkill().isHealingPotionSkill())
{ {
@@ -1456,7 +1459,7 @@ public final class CharEffectList
// Triggered buffs. // Triggered buffs.
if (hasTriggered()) if (hasTriggered())
{ {
for (BuffInfo info : getTriggered()) for (BuffInfo info : getTriggered().values())
{ {
addIcon(info, asu, ps, psSummon, os, isSummon); addIcon(info, asu, ps, psSummon, os, isSummon);
} }
@@ -1465,7 +1468,7 @@ public final class CharEffectList
// Songs and dances. // Songs and dances.
if (hasDances()) if (hasDances())
{ {
for (BuffInfo info : getDances()) for (BuffInfo info : getDances().values())
{ {
addIcon(info, asu, ps, psSummon, os, isSummon); addIcon(info, asu, ps, psSummon, os, isSummon);
} }
@@ -1474,7 +1477,7 @@ public final class CharEffectList
// Toggles. // Toggles.
if (hasToggles()) if (hasToggles())
{ {
for (BuffInfo info : getToggles()) for (BuffInfo info : getToggles().values())
{ {
addIcon(info, asu, ps, psSummon, os, isSummon); addIcon(info, asu, ps, psSummon, os, isSummon);
} }
@@ -1483,7 +1486,7 @@ public final class CharEffectList
// Debuffs. // Debuffs.
if (hasDebuffs()) if (hasDebuffs())
{ {
for (BuffInfo info : getDebuffs()) for (BuffInfo info : getDebuffs().values())
{ {
addIcon(info, asu, ps, psSummon, os, isSummon); addIcon(info, asu, ps, psSummon, os, isSummon);
} }
@@ -1603,7 +1606,7 @@ public final class CharEffectList
{ {
if (hasBuffs()) if (hasBuffs())
{ {
for (BuffInfo info : getBuffs()) for (BuffInfo info : getBuffs().values())
{ {
if (info == null) if (info == null)
{ {
@@ -1624,7 +1627,7 @@ public final class CharEffectList
if (hasTriggered()) if (hasTriggered())
{ {
for (BuffInfo info : getTriggered()) for (BuffInfo info : getTriggered().values())
{ {
if (info == null) if (info == null)
{ {
@@ -1645,7 +1648,7 @@ public final class CharEffectList
if (hasToggles()) if (hasToggles())
{ {
for (BuffInfo info : getToggles()) for (BuffInfo info : getToggles().values())
{ {
if (info == null) if (info == null)
{ {
@@ -1666,7 +1669,7 @@ public final class CharEffectList
if (hasDebuffs()) if (hasDebuffs())
{ {
for (BuffInfo info : getDebuffs()) for (BuffInfo info : getDebuffs().values())
{ {
if ((info != null) && info.getSkill().isRemovedOnDamage()) if ((info != null) && info.getSkill().isRemovedOnDamage())
{ {
@@ -1685,7 +1688,7 @@ public final class CharEffectList
int flags = 0; int flags = 0;
if (hasBuffs()) if (hasBuffs())
{ {
for (BuffInfo info : getBuffs()) for (BuffInfo info : getBuffs().values())
{ {
if (info != null) if (info != null)
{ {
@@ -1699,7 +1702,7 @@ public final class CharEffectList
if (hasTriggered()) if (hasTriggered())
{ {
for (BuffInfo info : getTriggered()) for (BuffInfo info : getTriggered().values())
{ {
if (info != null) if (info != null)
{ {
@@ -1713,7 +1716,7 @@ public final class CharEffectList
if (hasDebuffs()) if (hasDebuffs())
{ {
for (BuffInfo info : getDebuffs()) for (BuffInfo info : getDebuffs().values())
{ {
if (info != null) if (info != null)
{ {
@@ -1727,7 +1730,7 @@ public final class CharEffectList
if (hasDances()) if (hasDances())
{ {
for (BuffInfo info : getDances()) for (BuffInfo info : getDances().values())
{ {
if (info != null) if (info != null)
{ {
@@ -1741,7 +1744,7 @@ public final class CharEffectList
if (hasToggles()) if (hasToggles())
{ {
for (BuffInfo info : getToggles()) for (BuffInfo info : getToggles().values())
{ {
if (info != null) if (info != null)
{ {

View File

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

View File

@@ -3153,7 +3153,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public void resetCurrentAbnormalVisualEffects() public void resetCurrentAbnormalVisualEffects()
{ {
final Collection<BuffInfo> passives = getEffectList().hasPassives() ? new ArrayList<>(getEffectList().getPassives()) : null; final Collection<BuffInfo> passives = getEffectList().hasPassives() ? new ArrayList<>(getEffectList().getPassives().values()) : null;
//@formatter:off //@formatter:off
final Set<AbnormalVisualEffect> abnormalVisualEffects = Stream.concat(getEffectList().getEffects().stream(), passives != null ? passives.stream() : Stream.empty()) final Set<AbnormalVisualEffect> abnormalVisualEffects = Stream.concat(getEffectList().getEffects().stream(), passives != null ? passives.stream() : Stream.empty())
.filter(Objects::nonNull) .filter(Objects::nonNull)

View File

@@ -34,11 +34,9 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@@ -412,7 +410,7 @@ public final class L2PcInstance extends L2Playable
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_POINTS"; public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_POINTS";
private final Queue<IEventListener> _eventListeners = new ConcurrentLinkedQueue<>(); private final List<IEventListener> _eventListeners = new CopyOnWriteArrayList<>();
private L2GameClient _client; private L2GameClient _client;

View File

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

View File

@@ -2041,14 +2041,14 @@ public final class Formulas
} }
// Prevent initialization. // Prevent initialization.
final List<BuffInfo> buffs = target.getEffectList().hasBuffs() ? new ArrayList<>(target.getEffectList().getBuffs()) : new ArrayList<>(1); final List<BuffInfo> buffs = target.getEffectList().hasBuffs() ? new ArrayList<>(target.getEffectList().getBuffs().values()) : new ArrayList<>(1);
if (target.getEffectList().hasTriggered()) if (target.getEffectList().hasTriggered())
{ {
buffs.addAll(target.getEffectList().getTriggered()); buffs.addAll(target.getEffectList().getTriggered().values());
} }
if (target.getEffectList().hasDances()) if (target.getEffectList().hasDances())
{ {
buffs.addAll(target.getEffectList().getDances()); buffs.addAll(target.getEffectList().getDances().values());
} }
for (int i = buffs.size() - 1; i >= 0; i--) // reverse order for (int i = buffs.size() - 1; i >= 0; i--) // reverse order
{ {
@@ -2067,7 +2067,7 @@ public final class Formulas
} }
case "debuff": case "debuff":
{ {
final List<BuffInfo> debuffs = new ArrayList<>(target.getEffectList().getDebuffs()); final List<BuffInfo> debuffs = new ArrayList<>(target.getEffectList().getDebuffs().values());
for (int i = debuffs.size() - 1; i >= 0; i--) for (int i = debuffs.size() - 1; i >= 0; i--)
{ {
BuffInfo info = debuffs.get(i); BuffInfo info = debuffs.get(i);