Some synchronized changes.

This commit is contained in:
MobiusDev
2016-04-30 20:04:02 +00:00
parent 15d263a788
commit b001087964
17 changed files with 127 additions and 492 deletions

View File

@@ -25,6 +25,7 @@ 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.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;
@@ -64,21 +65,21 @@ 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. */ /** Queue containing all effects from buffs for this effect list. */
private volatile Queue<BuffInfo> _buffs; private volatile Queue<BuffInfo> _buffs = new ConcurrentLinkedQueue<>();
/** Queue containing all triggered skills for this effect list. */ /** Queue containing all triggered skills for this effect list. */
private volatile Queue<BuffInfo> _triggered; private volatile Queue<BuffInfo> _triggered = new ConcurrentLinkedQueue<>();
/** Queue containing all dances/songs for this effect list. */ /** Queue containing all dances/songs for this effect list. */
private volatile Queue<BuffInfo> _dances; private volatile Queue<BuffInfo> _dances = new ConcurrentLinkedQueue<>();
/** Queue containing all toggle for this effect list. */ /** Queue containing all toggle for this effect list. */
private volatile Queue<BuffInfo> _toggles; private volatile Queue<BuffInfo> _toggles = new ConcurrentLinkedQueue<>();
/** Queue containing all debuffs for this effect list. */ /** Queue containing all debuffs for this effect list. */
private volatile Queue<BuffInfo> _debuffs; private volatile Queue<BuffInfo> _debuffs = new ConcurrentLinkedQueue<>();
/** Queue containing all passives for this effect list. They bypass most of the actions and they are not included in most operations. */ /** 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; private volatile Queue<BuffInfo> _passives = new ConcurrentLinkedQueue<>();
/** 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 = new ConcurrentHashMap<>();
/** 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. */
private volatile Set<AbnormalType> _blockedBuffSlots = null; private volatile Set<AbnormalType> _blockedBuffSlots = new CopyOnWriteArraySet<>();
/** Short buff skill ID. */ /** Short buff skill ID. */
private BuffInfo _shortBuff = null; private BuffInfo _shortBuff = null;
/** If {@code true} this effect list has buffs removed on any action. */ /** If {@code true} this effect list has buffs removed on any action. */
@@ -113,16 +114,6 @@ public final class CharEffectList
*/ */
public Queue<BuffInfo> getBuffs() public Queue<BuffInfo> getBuffs()
{ {
if (_buffs == null)
{
synchronized (this)
{
if (_buffs == null)
{
_buffs = new ConcurrentLinkedQueue<>();
}
}
}
return _buffs; return _buffs;
} }
@@ -132,16 +123,6 @@ public final class CharEffectList
*/ */
public Queue<BuffInfo> getTriggered() public Queue<BuffInfo> getTriggered()
{ {
if (_triggered == null)
{
synchronized (this)
{
if (_triggered == null)
{
_triggered = new ConcurrentLinkedQueue<>();
}
}
}
return _triggered; return _triggered;
} }
@@ -151,16 +132,6 @@ public final class CharEffectList
*/ */
public Queue<BuffInfo> getDances() public Queue<BuffInfo> getDances()
{ {
if (_dances == null)
{
synchronized (this)
{
if (_dances == null)
{
_dances = new ConcurrentLinkedQueue<>();
}
}
}
return _dances; return _dances;
} }
@@ -170,16 +141,6 @@ public final class CharEffectList
*/ */
public Queue<BuffInfo> getToggles() public Queue<BuffInfo> getToggles()
{ {
if (_toggles == null)
{
synchronized (this)
{
if (_toggles == null)
{
_toggles = new ConcurrentLinkedQueue<>();
}
}
}
return _toggles; return _toggles;
} }
@@ -189,16 +150,6 @@ public final class CharEffectList
*/ */
public Queue<BuffInfo> getDebuffs() public Queue<BuffInfo> getDebuffs()
{ {
if (_debuffs == null)
{
synchronized (this)
{
if (_debuffs == null)
{
_debuffs = new ConcurrentLinkedQueue<>();
}
}
}
return _debuffs; return _debuffs;
} }
@@ -208,16 +159,6 @@ public final class CharEffectList
*/ */
public Queue<BuffInfo> getPassives() public Queue<BuffInfo> getPassives()
{ {
if (_passives == null)
{
synchronized (this)
{
if (_passives == null)
{
_passives = new ConcurrentLinkedQueue<>();
}
}
}
return _passives; return _passives;
} }
@@ -465,16 +406,6 @@ public final class CharEffectList
*/ */
public void addBlockedBuffSlots(Set<AbnormalType> blockedBuffSlots) public void addBlockedBuffSlots(Set<AbnormalType> blockedBuffSlots)
{ {
if (_blockedBuffSlots == null)
{
synchronized (this)
{
if (_blockedBuffSlots == null)
{
_blockedBuffSlots = ConcurrentHashMap.newKeySet(blockedBuffSlots.size());
}
}
}
_blockedBuffSlots.addAll(blockedBuffSlots); _blockedBuffSlots.addAll(blockedBuffSlots);
} }
@@ -1265,17 +1196,6 @@ public final class CharEffectList
// Verify stacked skills. // Verify stacked skills.
else else
{ {
if (_stackedEffects == null)
{
synchronized (this)
{
if (_stackedEffects == null)
{
_stackedEffects = new ConcurrentHashMap<>();
}
}
}
if (_stackedEffects.containsKey(skill.getAbnormalType())) if (_stackedEffects.containsKey(skill.getAbnormalType()))
{ {
BuffInfo stackedInfo = _stackedEffects.get(skill.getAbnormalType()); BuffInfo stackedInfo = _stackedEffects.get(skill.getAbnormalType());

View File

@@ -64,7 +64,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
private L2WorldRegion _worldRegion; private L2WorldRegion _worldRegion;
/** Instance type */ /** Instance type */
private InstanceType _instanceType = null; private InstanceType _instanceType = null;
private volatile Map<String, Object> _scripts; private volatile Map<String, Object> _scripts = new ConcurrentHashMap<>();
/** X coordinate */ /** X coordinate */
private final AtomicInteger _x = new AtomicInteger(0); private final AtomicInteger _x = new AtomicInteger(0);
/** Y coordinate */ /** Y coordinate */
@@ -531,16 +531,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/ */
public final <T> T addScript(T script) public final <T> T addScript(T script)
{ {
if (_scripts == null)
{
synchronized (this)
{
if (_scripts == null)
{
_scripts = new ConcurrentHashMap<>();
}
}
}
_scripts.put(script.getClass().getName(), script); _scripts.put(script.getClass().getName(), script);
return script; return script;
} }

View File

@@ -256,8 +256,6 @@ public class L2Attackable extends L2Npc
if (_firstCommandChannelAttacked == null) // looting right isn't set if (_firstCommandChannelAttacked == null) // looting right isn't set
{ {
synchronized (this) synchronized (this)
{
if (_firstCommandChannelAttacked == null)
{ {
_firstCommandChannelAttacked = attacker.getParty().getCommandChannel(); _firstCommandChannelAttacked = attacker.getParty().getCommandChannel();
if (_firstCommandChannelAttacked != null) if (_firstCommandChannelAttacked != null)
@@ -269,7 +267,6 @@ public class L2Attackable extends L2Npc
} }
} }
} }
}
else if (attacker.getParty().getCommandChannel().equals(_firstCommandChannelAttacked)) // is in same channel else if (attacker.getParty().getCommandChannel().equals(_firstCommandChannelAttacked)) // is in same channel
{ {
_commandChannelLastAttack = System.currentTimeMillis(); // update last attack time _commandChannelLastAttack = System.currentTimeMillis(); // update last attack time

View File

@@ -29,6 +29,7 @@ import java.util.Objects;
import java.util.Queue; 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.CopyOnWriteArraySet;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -190,7 +191,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{ {
public static final Logger _log = Logger.getLogger(L2Character.class.getName()); public static final Logger _log = Logger.getLogger(L2Character.class.getName());
private volatile Set<L2Character> _attackByList; private volatile Set<L2Character> _attackByList = new CopyOnWriteArraySet<>();
private volatile boolean _isCastingNow = false; private volatile boolean _isCastingNow = false;
private volatile boolean _isCastingSimultaneouslyNow = false; private volatile boolean _isCastingSimultaneouslyNow = false;
private Skill _lastSkillCast; private Skill _lastSkillCast;
@@ -225,11 +226,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
/** Map containing all skills of this character. */ /** Map containing all skills of this character. */
private final Map<Integer, Skill> _skills = new ConcurrentHashMap<>(); private final Map<Integer, Skill> _skills = new ConcurrentHashMap<>();
/** Map containing the skill reuse time stamps. */ /** Map containing the skill reuse time stamps. */
private volatile Map<Integer, TimeStamp> _reuseTimeStampsSkills = null; private volatile Map<Integer, TimeStamp> _reuseTimeStampsSkills = new ConcurrentHashMap<>();
/** Map containing the item reuse time stamps. */ /** Map containing the item reuse time stamps. */
private volatile Map<Integer, TimeStamp> _reuseTimeStampsItems = null; private volatile Map<Integer, TimeStamp> _reuseTimeStampsItems = new ConcurrentHashMap<>();
/** Map containing all the disabled skills. */ /** Map containing all the disabled skills. */
private volatile Map<Integer, Long> _disabledSkills = null; private volatile Map<Integer, Long> _disabledSkills = new ConcurrentHashMap<>();
private boolean _allSkillsDisabled; private boolean _allSkillsDisabled;
private final byte[] _zones = new byte[ZoneId.getZoneCount()]; private final byte[] _zones = new byte[ZoneId.getZoneCount()];
@@ -246,9 +247,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
private boolean _lethalable = true; private boolean _lethalable = true;
private volatile Map<Integer, OptionsSkillHolder> _triggerSkills; private volatile Map<Integer, OptionsSkillHolder> _triggerSkills = new ConcurrentHashMap<>();
private volatile Map<Integer, InvulSkillHolder> _invulAgainst; private volatile Map<Integer, InvulSkillHolder> _invulAgainst = new ConcurrentHashMap<>();
/** Creatures effect list. */ /** Creatures effect list. */
private final CharEffectList _effectList = new CharEffectList(this); private final CharEffectList _effectList = new CharEffectList(this);
/** The character that summons this character. */ /** The character that summons this character. */
@@ -258,8 +259,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
private SkillChannelized _channelized = null; private SkillChannelized _channelized = null;
private volatile Set<AbnormalVisualEffect> _abnormalVisualEffects; private volatile Set<AbnormalVisualEffect> _abnormalVisualEffects = new CopyOnWriteArraySet<>();
private volatile Set<AbnormalVisualEffect> _currentAbnormalVisualEffects; private volatile Set<AbnormalVisualEffect> _currentAbnormalVisualEffects = new CopyOnWriteArraySet<>();
/** Movement data of this L2Character */ /** Movement data of this L2Character */
protected MoveData _move; protected MoveData _move;
@@ -2135,16 +2136,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final void addTimeStampItem(L2ItemInstance item, long reuse, long systime) public final void addTimeStampItem(L2ItemInstance item, long reuse, long systime)
{ {
if (_reuseTimeStampsItems == null)
{
synchronized (this)
{
if (_reuseTimeStampsItems == null)
{
_reuseTimeStampsItems = new ConcurrentHashMap<>();
}
}
}
_reuseTimeStampsItems.put(item.getObjectId(), new TimeStamp(item, reuse, systime)); _reuseTimeStampsItems.put(item.getObjectId(), new TimeStamp(item, reuse, systime));
} }
@@ -2155,7 +2146,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final synchronized long getItemRemainingReuseTime(int itemObjId) public final synchronized long getItemRemainingReuseTime(int itemObjId)
{ {
final TimeStamp reuseStamp = (_reuseTimeStampsItems != null) ? _reuseTimeStampsItems.get(itemObjId) : null; final TimeStamp reuseStamp = _reuseTimeStampsItems.get(itemObjId);
return reuseStamp != null ? reuseStamp.getRemaining() : -1; return reuseStamp != null ? reuseStamp.getRemaining() : -1;
} }
@@ -2166,7 +2157,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final long getReuseDelayOnGroup(int group) public final long getReuseDelayOnGroup(int group)
{ {
if ((group > 0) && (_reuseTimeStampsItems != null)) if (group > 0)
{ {
for (TimeStamp ts : _reuseTimeStampsItems.values()) for (TimeStamp ts : _reuseTimeStampsItems.values())
{ {
@@ -2207,16 +2198,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final void addTimeStamp(Skill skill, long reuse, long systime) public final void addTimeStamp(Skill skill, long reuse, long systime)
{ {
if (_reuseTimeStampsSkills == null)
{
synchronized (this)
{
if (_reuseTimeStampsSkills == null)
{
_reuseTimeStampsSkills = new ConcurrentHashMap<>();
}
}
}
_reuseTimeStampsSkills.put(skill.getReuseHashCode(), new TimeStamp(skill, reuse, systime)); _reuseTimeStampsSkills.put(skill.getReuseHashCode(), new TimeStamp(skill, reuse, systime));
} }
@@ -2225,23 +2206,17 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
* @param skill the skill to remove * @param skill the skill to remove
*/ */
public final synchronized void removeTimeStamp(Skill skill) public final synchronized void removeTimeStamp(Skill skill)
{
if (_reuseTimeStampsSkills != null)
{ {
_reuseTimeStampsSkills.remove(skill.getReuseHashCode()); _reuseTimeStampsSkills.remove(skill.getReuseHashCode());
} }
}
/** /**
* Removes all skill reuse time stamps. * Removes all skill reuse time stamps.
*/ */
public final synchronized void resetTimeStamps() public final synchronized void resetTimeStamps()
{
if (_reuseTimeStampsSkills != null)
{ {
_reuseTimeStampsSkills.clear(); _reuseTimeStampsSkills.clear();
} }
}
/** /**
* Gets the skill remaining reuse time for a given skill hash code. * Gets the skill remaining reuse time for a given skill hash code.
@@ -2250,7 +2225,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final synchronized long getSkillRemainingReuseTime(int hashCode) public final synchronized long getSkillRemainingReuseTime(int hashCode)
{ {
final TimeStamp reuseStamp = (_reuseTimeStampsSkills != null) ? _reuseTimeStampsSkills.get(hashCode) : null; final TimeStamp reuseStamp = _reuseTimeStampsSkills.get(hashCode);
return reuseStamp != null ? reuseStamp.getRemaining() : -1; return reuseStamp != null ? reuseStamp.getRemaining() : -1;
} }
@@ -2261,7 +2236,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final synchronized boolean hasSkillReuse(int hashCode) public final synchronized boolean hasSkillReuse(int hashCode)
{ {
final TimeStamp reuseStamp = (_reuseTimeStampsSkills != null) ? _reuseTimeStampsSkills.get(hashCode) : null; final TimeStamp reuseStamp = _reuseTimeStampsSkills.get(hashCode);
return (reuseStamp != null) && reuseStamp.hasNotPassed(); return (reuseStamp != null) && reuseStamp.hasNotPassed();
} }
@@ -2272,7 +2247,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final synchronized TimeStamp getSkillReuseTimeStamp(int hashCode) public final synchronized TimeStamp getSkillReuseTimeStamp(int hashCode)
{ {
return _reuseTimeStampsSkills != null ? _reuseTimeStampsSkills.get(hashCode) : null; return _reuseTimeStampsSkills.get(hashCode);
} }
/** /**
@@ -2290,7 +2265,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public void enableSkill(Skill skill) public void enableSkill(Skill skill)
{ {
if ((skill == null) || (_disabledSkills == null)) if (skill == null)
{ {
return; return;
} }
@@ -2309,18 +2284,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{ {
return; return;
} }
if (_disabledSkills == null)
{
synchronized (this)
{
if (_disabledSkills == null)
{
_disabledSkills = new ConcurrentHashMap<>();
}
}
}
_disabledSkills.put(skill.getReuseHashCode(), delay > 0 ? System.currentTimeMillis() + delay : Long.MAX_VALUE); _disabledSkills.put(skill.getReuseHashCode(), delay > 0 ? System.currentTimeMillis() + delay : Long.MAX_VALUE);
} }
@@ -2328,12 +2291,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
* Removes all the disabled skills. * Removes all the disabled skills.
*/ */
public final synchronized void resetDisabledSkills() public final synchronized void resetDisabledSkills()
{
if (_disabledSkills != null)
{ {
_disabledSkills.clear(); _disabledSkills.clear();
} }
}
/** /**
* Verifies if the skill is disabled. * Verifies if the skill is disabled.
@@ -2357,7 +2317,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
return true; return true;
} }
if (_disabledSkills == null) if (_disabledSkills.isEmpty())
{ {
return false; return false;
} }
@@ -2454,7 +2414,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
getWorldRegion().onDeath(this); getWorldRegion().onDeath(this);
} }
getAttackByList().clear(); clearAttackByList();
if (isChannelized()) if (isChannelized())
{ {
@@ -2554,15 +2514,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
if (_ai == null) if (_ai == null)
{ {
synchronized (this) synchronized (this)
{
if (_ai == null)
{ {
// Return the new AI within the synchronized block // Return the new AI within the synchronized block
// to avoid being nulled by other threads // to avoid being nulled by other threads
return _ai = initAI(); return _ai = initAI();
} }
} }
}
return _ai; return _ai;
} }
@@ -2624,19 +2581,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public final Set<L2Character> getAttackByList() public final Set<L2Character> getAttackByList()
{ {
if (_attackByList == null)
{
synchronized (this)
{
if (_attackByList == null)
{
_attackByList = ConcurrentHashMap.newKeySet();
}
}
}
return _attackByList; return _attackByList;
} }
public void clearAttackByList()
{
_attackByList.clear();
}
public final Skill getLastSimultaneousSkillCast() public final Skill getLastSimultaneousSkillCast()
{ {
return _lastSimultaneousSkillCast; return _lastSimultaneousSkillCast;
@@ -3135,12 +3087,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));
//@formatter:on //@formatter:on
if (_abnormalVisualEffects != null) if (!_abnormalVisualEffects.isEmpty())
{ {
abnormalVisualEffects.addAll(_abnormalVisualEffects); abnormalVisualEffects.addAll(_abnormalVisualEffects);
} }
if ((_currentAbnormalVisualEffects == null) || !_currentAbnormalVisualEffects.equals(abnormalVisualEffects)) if ((_currentAbnormalVisualEffects.isEmpty()) || !_currentAbnormalVisualEffects.equals(abnormalVisualEffects))
{ {
_currentAbnormalVisualEffects = abnormalVisualEffects; _currentAbnormalVisualEffects = abnormalVisualEffects;
updateAbnormalVisualEffects(); updateAbnormalVisualEffects();
@@ -3153,7 +3105,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public Set<AbnormalVisualEffect> getCurrentAbnormalVisualEffects() public Set<AbnormalVisualEffect> getCurrentAbnormalVisualEffects()
{ {
return _currentAbnormalVisualEffects != null ? _currentAbnormalVisualEffects : Collections.emptySet(); return _currentAbnormalVisualEffects;
} }
/** /**
@@ -3163,7 +3115,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/ */
public boolean hasAbnormalVisualEffect(AbnormalVisualEffect ave) public boolean hasAbnormalVisualEffect(AbnormalVisualEffect ave)
{ {
return (_abnormalVisualEffects != null) && _abnormalVisualEffects.contains(ave); return _abnormalVisualEffects.contains(ave);
} }
/** /**
@@ -3174,16 +3126,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{ {
for (AbnormalVisualEffect ave : aves) for (AbnormalVisualEffect ave : aves)
{ {
if (_abnormalVisualEffects == null)
{
synchronized (this)
{
if (_abnormalVisualEffects == null)
{
_abnormalVisualEffects = Collections.newSetFromMap(new ConcurrentHashMap<>());
}
}
}
_abnormalVisualEffects.add(ave); _abnormalVisualEffects.add(ave);
} }
resetCurrentAbnormalVisualEffects(); resetCurrentAbnormalVisualEffects();
@@ -3194,8 +3136,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
* @param aves the abnormal visual effects * @param aves the abnormal visual effects
*/ */
public final void stopAbnormalVisualEffect(AbnormalVisualEffect... aves) public final void stopAbnormalVisualEffect(AbnormalVisualEffect... aves)
{
if (_abnormalVisualEffects != null)
{ {
for (AbnormalVisualEffect ave : aves) for (AbnormalVisualEffect ave : aves)
{ {
@@ -3203,7 +3143,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
} }
resetCurrentAbnormalVisualEffects(); resetCurrentAbnormalVisualEffects();
} }
}
/** /**
* Active the abnormal effect Fake Death flag, notify the L2Character AI and send Server->Client UserInfo/CharInfo packet. * Active the abnormal effect Fake Death flag, notify the L2Character AI and send Server->Client UserInfo/CharInfo packet.
@@ -4953,8 +4892,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
target.breakCast(); target.breakCast();
} }
if (_triggerSkills != null)
{
for (OptionsSkillHolder holder : _triggerSkills.values()) for (OptionsSkillHolder holder : _triggerSkills.values())
{ {
if (((!crit && (holder.getSkillType() == OptionsSkillType.ATTACK)) || ((holder.getSkillType() == OptionsSkillType.CRITICAL) && crit)) && (Rnd.get(100) < holder.getChance())) if (((!crit && (holder.getSkillType() == OptionsSkillType.ATTACK)) || ((holder.getSkillType() == OptionsSkillType.CRITICAL) && crit)) && (Rnd.get(100) < holder.getChance()))
@@ -4962,7 +4899,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
makeTriggerCast(holder.getSkill(), target); makeTriggerCast(holder.getSkill(), target);
} }
} }
}
// Launch weapon onCritical Special ability effect if available // Launch weapon onCritical Special ability effect if available
if (crit && (weapon != null)) if (crit && (weapon != null))
{ {
@@ -5748,8 +5685,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
activeWeapon.castOnMagicSkill(this, target, skill); activeWeapon.castOnMagicSkill(this, target, skill);
} }
if (_triggerSkills != null)
{
for (OptionsSkillHolder holder : _triggerSkills.values()) for (OptionsSkillHolder holder : _triggerSkills.values())
{ {
if (((skill.isMagic() && (holder.getSkillType() == OptionsSkillType.MAGIC)) || (skill.isPhysical() && (holder.getSkillType() == OptionsSkillType.ATTACK))) && (Rnd.get(100) < holder.getChance())) if (((skill.isMagic() && (holder.getSkillType() == OptionsSkillType.MAGIC)) || (skill.isPhysical() && (holder.getSkillType() == OptionsSkillType.ATTACK))) && (Rnd.get(100) < holder.getChance()))
@@ -5759,7 +5694,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
} }
} }
} }
}
// Launch the magic skill and calculate its effects // Launch the magic skill and calculate its effects
skill.activateSkill(this, targets); skill.activateSkill(this, targets);
@@ -6506,16 +6440,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
public Map<Integer, OptionsSkillHolder> getTriggerSkills() public Map<Integer, OptionsSkillHolder> getTriggerSkills()
{ {
if (_triggerSkills == null)
{
synchronized (this)
{
if (_triggerSkills == null)
{
_triggerSkills = new ConcurrentHashMap<>();
}
}
}
return _triggerSkills; return _triggerSkills;
} }
@@ -6793,7 +6717,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
public boolean isInvulAgainst(int skillId, int skillLvl) public boolean isInvulAgainst(int skillId, int skillLvl)
{ {
if (_invulAgainst == null) if (_invulAgainst.isEmpty())
{ {
return false; return false;
} }
@@ -6803,16 +6727,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
private Map<Integer, InvulSkillHolder> getInvulAgainstSkills() private Map<Integer, InvulSkillHolder> getInvulAgainstSkills()
{ {
if (_invulAgainst == null)
{
synchronized (this)
{
if (_invulAgainst == null)
{
_invulAgainst = new ConcurrentHashMap<>();
}
}
}
return _invulAgainst; return _invulAgainst;
} }

View File

@@ -144,7 +144,7 @@ public class L2Npc extends L2Character
private int _shotsMask = 0; private int _shotsMask = 0;
private int _killingBlowWeaponId; private int _killingBlowWeaponId;
/** Map of summoned NPCs by this NPC. */ /** Map of summoned NPCs by this NPC. */
private volatile Map<Integer, L2Npc> _summonedNpcs = null; private volatile Map<Integer, L2Npc> _summonedNpcs = new ConcurrentHashMap<>();
/** /**
* Creates a NPC. * Creates a NPC.
@@ -1685,19 +1685,7 @@ public class L2Npc extends L2Character
*/ */
public final void addSummonedNpc(L2Npc npc) public final void addSummonedNpc(L2Npc npc)
{ {
if (_summonedNpcs == null)
{
synchronized (this)
{
if (_summonedNpcs == null)
{
_summonedNpcs = new ConcurrentHashMap<>();
}
}
}
_summonedNpcs.put(npc.getObjectId(), npc); _summonedNpcs.put(npc.getObjectId(), npc);
npc.setSummoner(this); npc.setSummoner(this);
} }

View File

@@ -171,8 +171,6 @@ public class L2ClanHallDoormenInstance extends L2DoormenInstance
if (!_init) if (!_init)
{ {
synchronized (this) synchronized (this)
{
if (!_init)
{ {
_clanHall = ClanHallManager.getInstance().getNearbyClanHall(getX(), getY(), 500); _clanHall = ClanHallManager.getInstance().getNearbyClanHall(getX(), getY(), 500);
if (_clanHall != null) if (_clanHall != null)
@@ -182,7 +180,6 @@ public class L2ClanHallDoormenInstance extends L2DoormenInstance
_init = true; _init = true;
} }
} }
}
return _clanHall; return _clanHall;
} }

View File

@@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/ */
public class L2ControlTowerInstance extends L2Tower public class L2ControlTowerInstance extends L2Tower
{ {
private volatile List<L2Spawn> _guards; private volatile List<L2Spawn> _guards = new CopyOnWriteArrayList<>();
/** /**
* Creates a control tower. * Creates a control tower.
@@ -50,8 +50,6 @@ public class L2ControlTowerInstance extends L2Tower
{ {
getCastle().getSiege().killedCT(this); getCastle().getSiege().killedCT(this);
if ((_guards != null) && !_guards.isEmpty())
{
for (L2Spawn spawn : _guards) for (L2Spawn spawn : _guards)
{ {
try try
@@ -66,7 +64,6 @@ public class L2ControlTowerInstance extends L2Tower
} }
_guards.clear(); _guards.clear();
} }
}
return super.doDie(killer); return super.doDie(killer);
} }
@@ -77,16 +74,6 @@ public class L2ControlTowerInstance extends L2Tower
private final List<L2Spawn> getGuards() private final List<L2Spawn> getGuards()
{ {
if (_guards == null)
{
synchronized (this)
{
if (_guards == null)
{
_guards = new CopyOnWriteArrayList<>();
}
}
}
return _guards; return _guards;
} }
} }

View File

@@ -192,13 +192,10 @@ public class L2MonsterInstance extends L2Attackable
if (_minionList == null) if (_minionList == null)
{ {
synchronized (this) synchronized (this)
{
if (_minionList == null)
{ {
_minionList = new MinionList(this); _minionList = new MinionList(this);
} }
} }
}
return _minionList; return _minionList;
} }

View File

@@ -518,7 +518,7 @@ public final class L2PcInstance extends L2Playable
private long _offlineShopStart = 0; private long _offlineShopStart = 0;
private Transform _transformation; private Transform _transformation;
private volatile Map<Integer, Skill> _transformSkills; private volatile Map<Integer, Skill> _transformSkills = new ConcurrentHashMap<>();
/** The table containing all L2RecipeList of the L2PcInstance */ /** The table containing all L2RecipeList of the L2PcInstance */
private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new ConcurrentHashMap<>(); private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new ConcurrentHashMap<>();
@@ -607,7 +607,7 @@ public final class L2PcInstance extends L2Playable
/** The Pet of the L2PcInstance */ /** The Pet of the L2PcInstance */
private L2Summon _pet = null; private L2Summon _pet = null;
/** Servitors of the L2PcInstance */ /** Servitors of the L2PcInstance */
private volatile Map<Integer, L2Summon> _servitors = null; private volatile Map<Integer, L2Summon> _servitors = new ConcurrentHashMap<>();
private int _usedSummonPoints = 0; private int _usedSummonPoints = 0;
/** The L2Decoy of the L2PcInstance */ /** The L2Decoy of the L2PcInstance */
private L2Decoy _decoy = null; private L2Decoy _decoy = null;
@@ -693,7 +693,7 @@ public final class L2PcInstance extends L2Playable
private L2ItemInstance _lure = null; private L2ItemInstance _lure = null;
private volatile Map<Integer, ExResponseCommissionInfo> _lastCommissionInfos; private volatile Map<Integer, ExResponseCommissionInfo> _lastCommissionInfos = new ConcurrentHashMap<>();
public boolean isSpawnProtected() public boolean isSpawnProtected()
{ {
@@ -722,7 +722,7 @@ public final class L2PcInstance extends L2Playable
private int _expertiseWeaponPenalty = 0; private int _expertiseWeaponPenalty = 0;
private int _expertisePenaltyBonus = 0; private int _expertisePenaltyBonus = 0;
private volatile Map<Class<? extends AbstractRequest>, AbstractRequest> _requests; private volatile Map<Class<? extends AbstractRequest>, AbstractRequest> _requests = new ConcurrentHashMap<>();
protected boolean _inventoryDisable = false; protected boolean _inventoryDisable = false;
/** Player's cubics. */ /** Player's cubics. */
@@ -1534,7 +1534,7 @@ public final class L2PcInstance extends L2Playable
} }
/** List of all QuestState instance that needs to be notified of this L2PcInstance's or its pet's death */ /** List of all QuestState instance that needs to be notified of this L2PcInstance's or its pet's death */
private volatile List<QuestState> _notifyQuestOfDeathList; private volatile List<QuestState> _notifyQuestOfDeathList = new CopyOnWriteArrayList<>();
/** /**
* Add QuestState instance that is to be notified of L2PcInstance's death. * Add QuestState instance that is to be notified of L2PcInstance's death.
@@ -1559,11 +1559,10 @@ public final class L2PcInstance extends L2Playable
*/ */
public void removeNotifyQuestOfDeath(QuestState qs) public void removeNotifyQuestOfDeath(QuestState qs)
{ {
if ((qs == null) || (_notifyQuestOfDeathList == null)) if (qs == null)
{ {
return; return;
} }
_notifyQuestOfDeathList.remove(qs); _notifyQuestOfDeathList.remove(qs);
} }
@@ -1572,23 +1571,12 @@ public final class L2PcInstance extends L2Playable
*/ */
public final List<QuestState> getNotifyQuestOfDeath() public final List<QuestState> getNotifyQuestOfDeath()
{ {
if (_notifyQuestOfDeathList == null)
{
synchronized (this)
{
if (_notifyQuestOfDeathList == null)
{
_notifyQuestOfDeathList = new CopyOnWriteArrayList<>();
}
}
}
return _notifyQuestOfDeathList; return _notifyQuestOfDeathList;
} }
public final boolean isNotifyQuestOfDeathEmpty() public final boolean isNotifyQuestOfDeathEmpty()
{ {
return (_notifyQuestOfDeathList == null) || _notifyQuestOfDeathList.isEmpty(); return _notifyQuestOfDeathList.isEmpty();
} }
/** /**
@@ -5755,7 +5743,7 @@ public final class L2PcInstance extends L2Playable
@Override @Override
public Map<Integer, L2Summon> getServitors() public Map<Integer, L2Summon> getServitors()
{ {
return _servitors == null ? Collections.emptyMap() : _servitors; return _servitors;
} }
public L2Summon getAnyServitor() public L2Summon getAnyServitor()
@@ -5796,16 +5784,6 @@ public final class L2PcInstance extends L2Playable
public void addServitor(L2Summon servitor) public void addServitor(L2Summon servitor)
{ {
if (_servitors == null)
{
synchronized (this)
{
if (_servitors == null)
{
_servitors = new ConcurrentHashMap<>(1);
}
}
}
_servitors.put(servitor.getObjectId(), servitor); _servitors.put(servitor.getObjectId(), servitor);
} }
@@ -6035,13 +6013,10 @@ public final class L2PcInstance extends L2Playable
if (_manufactureItems == null) if (_manufactureItems == null)
{ {
synchronized (this) synchronized (this)
{
if (_manufactureItems == null)
{ {
_manufactureItems = Collections.synchronizedMap(new LinkedHashMap<Integer, L2ManufactureItem>()); _manufactureItems = Collections.synchronizedMap(new LinkedHashMap<Integer, L2ManufactureItem>());
} }
} }
}
return _manufactureItems; return _manufactureItems;
} }
@@ -11064,14 +11039,11 @@ public final class L2PcInstance extends L2Playable
if ((_teleportWatchdog == null) && (Config.TELEPORT_WATCHDOG_TIMEOUT > 0)) if ((_teleportWatchdog == null) && (Config.TELEPORT_WATCHDOG_TIMEOUT > 0))
{ {
synchronized (this) synchronized (this)
{
if (_teleportWatchdog == null)
{ {
_teleportWatchdog = ThreadPoolManager.getInstance().scheduleGeneral(new TeleportWatchdogTask(this), Config.TELEPORT_WATCHDOG_TIMEOUT * 1000); _teleportWatchdog = ThreadPoolManager.getInstance().scheduleGeneral(new TeleportWatchdogTask(this), Config.TELEPORT_WATCHDOG_TIMEOUT * 1000);
} }
} }
} }
}
else if (_teleportWatchdog != null) else if (_teleportWatchdog != null)
{ {
_teleportWatchdog.cancel(false); _teleportWatchdog.cancel(false);
@@ -12814,16 +12786,6 @@ public final class L2PcInstance extends L2Playable
public void addTransformSkill(Skill sk) public void addTransformSkill(Skill sk)
{ {
if (_transformSkills == null)
{
synchronized (this)
{
if (_transformSkills == null)
{
_transformSkills = new ConcurrentHashMap<>();
}
}
}
_transformSkills.put(sk.getId(), sk); _transformSkills.put(sk.getId(), sk);
if (sk.isPassive()) if (sk.isPassive())
{ {
@@ -12833,17 +12795,17 @@ public final class L2PcInstance extends L2Playable
public Skill getTransformSkill(int id) public Skill getTransformSkill(int id)
{ {
return _transformSkills == null ? null : _transformSkills.get(id); return _transformSkills.get(id);
} }
public boolean hasTransformSkill(int id) public boolean hasTransformSkill(int id)
{ {
return (_transformSkills != null) && _transformSkills.containsKey(id); return _transformSkills.containsKey(id);
} }
public void removeAllTransformSkills() public void removeAllTransformSkills()
{ {
_transformSkills = null; _transformSkills.clear();
} }
protected void startFeed(int npcId) protected void startFeed(int npcId)
@@ -13075,13 +13037,10 @@ public final class L2PcInstance extends L2Playable
if (_chargeTask != null) if (_chargeTask != null)
{ {
synchronized (this) synchronized (this)
{
if (_chargeTask != null)
{ {
_chargeTask.cancel(false); _chargeTask.cancel(false);
} }
} }
}
_chargeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ResetChargesTask(this), 600000); _chargeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ResetChargesTask(this), 600000);
} }
@@ -14946,22 +14905,12 @@ public final class L2PcInstance extends L2Playable
*/ */
public boolean addRequest(AbstractRequest request) public boolean addRequest(AbstractRequest request)
{ {
if (_requests == null)
{
synchronized (this)
{
if (_requests == null)
{
_requests = new ConcurrentHashMap<>();
}
}
}
return canRequest(request) && (_requests.putIfAbsent(request.getClass(), request) == null); return canRequest(request) && (_requests.putIfAbsent(request.getClass(), request) == null);
} }
public boolean canRequest(AbstractRequest request) public boolean canRequest(AbstractRequest request)
{ {
return (_requests != null) && _requests.values().stream().allMatch(request::canWorkWith); return _requests.values().stream().allMatch(request::canWorkWith);
} }
/** /**
@@ -14970,7 +14919,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public boolean removeRequest(Class<? extends AbstractRequest> clazz) public boolean removeRequest(Class<? extends AbstractRequest> clazz)
{ {
return (_requests != null) && (_requests.remove(clazz) != null); return (_requests.remove(clazz) != null);
} }
/** /**
@@ -14980,7 +14929,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public <T extends AbstractRequest> T getRequest(Class<T> requestClass) public <T extends AbstractRequest> T getRequest(Class<T> requestClass)
{ {
return _requests != null ? requestClass.cast(_requests.get(requestClass)) : null; return requestClass.cast(_requests.get(requestClass));
} }
/** /**
@@ -14988,12 +14937,12 @@ public final class L2PcInstance extends L2Playable
*/ */
public boolean hasRequests() public boolean hasRequests()
{ {
return (_requests != null) && !_requests.isEmpty(); return !_requests.isEmpty();
} }
public boolean hasItemRequest() public boolean hasItemRequest()
{ {
return (_requests != null) && _requests.values().stream().anyMatch(AbstractRequest::isItemRequest); return _requests.values().stream().anyMatch(AbstractRequest::isItemRequest);
} }
/** /**
@@ -15004,7 +14953,7 @@ public final class L2PcInstance extends L2Playable
@SafeVarargs @SafeVarargs
public final boolean hasRequest(Class<? extends AbstractRequest> requestClass, Class<? extends AbstractRequest>... classes) public final boolean hasRequest(Class<? extends AbstractRequest> requestClass, Class<? extends AbstractRequest>... classes)
{ {
if (_requests == null) if (_requests.isEmpty())
{ {
return false; return false;
} }
@@ -15024,7 +14973,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public boolean isProcessingItem(int objectId) public boolean isProcessingItem(int objectId)
{ {
return (_requests != null) && _requests.values().stream().anyMatch(req -> req.isUsing(objectId)); return _requests.values().stream().anyMatch(req -> req.isUsing(objectId));
} }
/** /**
@@ -15032,12 +14981,9 @@ public final class L2PcInstance extends L2Playable
* @param objectId * @param objectId
*/ */
public void removeRequestsThatProcessesItem(int objectId) public void removeRequestsThatProcessesItem(int objectId)
{
if (_requests != null)
{ {
_requests.values().removeIf(req -> req.isUsing(objectId)); _requests.values().removeIf(req -> req.isUsing(objectId));
} }
}
/* /*
* Return current vitality points in integer format * Return current vitality points in integer format
@@ -15095,16 +15041,6 @@ public final class L2PcInstance extends L2Playable
*/ */
public Map<Integer, ExResponseCommissionInfo> getLastCommissionInfos() public Map<Integer, ExResponseCommissionInfo> getLastCommissionInfos()
{ {
if (_lastCommissionInfos == null)
{
synchronized (this)
{
if (_lastCommissionInfos == null)
{
_lastCommissionInfos = new ConcurrentHashMap<>();
}
}
}
return _lastCommissionInfos; return _lastCommissionInfos;
} }

View File

@@ -29,9 +29,9 @@ import com.l2jmobius.gameserver.util.Util;
public class CharKnownList extends ObjectKnownList public class CharKnownList extends ObjectKnownList
{ {
private volatile Map<Integer, L2PcInstance> _knownPlayers; private volatile Map<Integer, L2PcInstance> _knownPlayers = new ConcurrentHashMap<>();
private volatile Map<Integer, L2Summon> _knownSummons; private volatile Map<Integer, L2Summon> _knownSummons = new ConcurrentHashMap<>();
private volatile Map<Integer, Integer> _knownRelations; private volatile Map<Integer, Integer> _knownRelations = new ConcurrentHashMap<>();
public CharKnownList(L2Character activeChar) public CharKnownList(L2Character activeChar)
{ {
@@ -225,46 +225,16 @@ public class CharKnownList extends ObjectKnownList
public final Map<Integer, L2PcInstance> getKnownPlayers() public final Map<Integer, L2PcInstance> getKnownPlayers()
{ {
if (_knownPlayers == null)
{
synchronized (this)
{
if (_knownPlayers == null)
{
_knownPlayers = new ConcurrentHashMap<>();
}
}
}
return _knownPlayers; return _knownPlayers;
} }
public final Map<Integer, Integer> getKnownRelations() public final Map<Integer, Integer> getKnownRelations()
{ {
if (_knownRelations == null)
{
synchronized (this)
{
if (_knownRelations == null)
{
_knownRelations = new ConcurrentHashMap<>();
}
}
}
return _knownRelations; return _knownRelations;
} }
public final Map<Integer, L2Summon> getKnownSummons() public final Map<Integer, L2Summon> getKnownSummons()
{ {
if (_knownSummons == null)
{
synchronized (this)
{
if (_knownSummons == null)
{
_knownSummons = new ConcurrentHashMap<>();
}
}
}
return _knownSummons; return _knownSummons;
} }

View File

@@ -27,7 +27,7 @@ import com.l2jmobius.gameserver.util.Util;
public class ObjectKnownList public class ObjectKnownList
{ {
private final L2Object _activeObject; private final L2Object _activeObject;
private volatile Map<Integer, L2Object> _knownObjects; private volatile Map<Integer, L2Object> _knownObjects = new ConcurrentHashMap<>();
public ObjectKnownList(L2Object activeObject) public ObjectKnownList(L2Object activeObject)
{ {
@@ -193,16 +193,6 @@ public class ObjectKnownList
*/ */
public final Map<Integer, L2Object> getKnownObjects() public final Map<Integer, L2Object> getKnownObjects()
{ {
if (_knownObjects == null)
{
synchronized (this)
{
if (_knownObjects == null)
{
_knownObjects = new ConcurrentHashMap<>();
}
}
}
return _knownObjects; return _knownObjects;
} }
} }

View File

@@ -889,13 +889,10 @@ public final class Fort extends AbstractResidence
if (_siege == null) if (_siege == null)
{ {
synchronized (this) synchronized (this)
{
if (_siege == null)
{ {
_siege = new FortSiege(this); _siege = new FortSiege(this);
} }
} }
}
return _siege; return _siege;
} }

View File

@@ -30,7 +30,7 @@ import com.l2jmobius.util.EmptyQueue;
*/ */
public class ListenersContainer public class ListenersContainer
{ {
private volatile Map<EventType, Queue<AbstractEventListener>> _listeners = null; private volatile Map<EventType, Queue<AbstractEventListener>> _listeners = new ConcurrentHashMap<>();
/** /**
* Registers listener for a callback when specified event is executed. * Registers listener for a callback when specified event is executed.
@@ -58,10 +58,6 @@ public class ListenersContainer
{ {
throw new NullPointerException("Listener cannot be null!"); throw new NullPointerException("Listener cannot be null!");
} }
else if (_listeners == null)
{
throw new NullPointerException("Listeners container is not initialized!");
}
else if (!_listeners.containsKey(listener.getType())) else if (!_listeners.containsKey(listener.getType()))
{ {
throw new IllegalAccessError("Listeners container doesn't had " + listener.getType() + " event type added!"); throw new IllegalAccessError("Listeners container doesn't had " + listener.getType() + " event type added!");
@@ -77,7 +73,7 @@ public class ListenersContainer
*/ */
public Queue<AbstractEventListener> getListeners(EventType type) public Queue<AbstractEventListener> getListeners(EventType type)
{ {
return (_listeners != null) && _listeners.containsKey(type) ? _listeners.get(type) : EmptyQueue.emptyQueue(); return _listeners.containsKey(type) ? _listeners.get(type) : EmptyQueue.emptyQueue();
} }
public void removeListenerIf(EventType type, Predicate<? super AbstractEventListener> filter) public void removeListenerIf(EventType type, Predicate<? super AbstractEventListener> filter)
@@ -86,12 +82,9 @@ public class ListenersContainer
} }
public void removeListenerIf(Predicate<? super AbstractEventListener> filter) public void removeListenerIf(Predicate<? super AbstractEventListener> filter)
{
if (_listeners != null)
{ {
getListeners().values().forEach(queue -> queue.stream().filter(filter).forEach(AbstractEventListener::unregisterMe)); getListeners().values().forEach(queue -> queue.stream().filter(filter).forEach(AbstractEventListener::unregisterMe));
} }
}
public boolean hasListener(EventType type) public boolean hasListener(EventType type)
{ {
@@ -104,16 +97,6 @@ public class ListenersContainer
*/ */
private Map<EventType, Queue<AbstractEventListener>> getListeners() private Map<EventType, Queue<AbstractEventListener>> getListeners()
{ {
if (_listeners == null)
{
synchronized (this)
{
if (_listeners == null)
{
_listeners = new ConcurrentHashMap<>();
}
}
}
return _listeners; return _listeners;
} }
} }

View File

@@ -245,13 +245,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if (_questTimers == null) if (_questTimers == null)
{ {
synchronized (this) synchronized (this)
{
if (_questTimers == null)
{ {
_questTimers = new ConcurrentHashMap<>(1); _questTimers = new ConcurrentHashMap<>(1);
} }
} }
}
return _questTimers; return _questTimers;
} }
@@ -2798,13 +2795,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if (_startCondition == null) if (_startCondition == null)
{ {
synchronized (this) synchronized (this)
{
if (_startCondition == null)
{ {
_startCondition = new LinkedHashMap<>(1); _startCondition = new LinkedHashMap<>(1);
} }
} }
}
return _startCondition; return _startCondition;
} }

View File

@@ -51,7 +51,7 @@ public final class BuffInfo
private final List<AbstractEffect> _effects = new ArrayList<>(1); private final List<AbstractEffect> _effects = new ArrayList<>(1);
// Tasks // Tasks
/** Effect tasks for ticks. */ /** Effect tasks for ticks. */
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks; private volatile Map<AbstractEffect, EffectTaskInfo> _tasks = new ConcurrentHashMap<>();
/** Scheduled future. */ /** Scheduled future. */
private ScheduledFuture<?> _scheduledFutureTimeTask; private ScheduledFuture<?> _scheduledFutureTimeTask;
// Time and ticks // Time and ticks
@@ -106,16 +106,6 @@ public final class BuffInfo
*/ */
private void addTask(AbstractEffect effect, EffectTaskInfo effectTaskInfo) private void addTask(AbstractEffect effect, EffectTaskInfo effectTaskInfo)
{ {
if (_tasks == null)
{
synchronized (this)
{
if (_tasks == null)
{
_tasks = new ConcurrentHashMap<>();
}
}
}
_tasks.put(effect, effectTaskInfo); _tasks.put(effect, effectTaskInfo);
} }
@@ -126,7 +116,7 @@ public final class BuffInfo
*/ */
private EffectTaskInfo getEffectTask(AbstractEffect effect) private EffectTaskInfo getEffectTask(AbstractEffect effect)
{ {
return (_tasks == null) ? null : _tasks.get(effect); return _tasks.get(effect);
} }
/** /**
@@ -318,13 +308,10 @@ public final class BuffInfo
public void finishEffects() public void finishEffects()
{ {
// Cancels the ticking task. // Cancels the ticking task.
if (_tasks != null)
{
for (EffectTaskInfo effectTask : _tasks.values()) for (EffectTaskInfo effectTask : _tasks.values())
{ {
effectTask.getScheduledFuture().cancel(true); // Don't allow to finish current run. effectTask.getScheduledFuture().cancel(true); // Don't allow to finish current run.
} }
}
// Remove stats // Remove stats
removeStats(); removeStats();
// Notify on exit. // Notify on exit.
@@ -404,15 +391,12 @@ public final class BuffInfo
* @return the current tick count * @return the current tick count
*/ */
public int getTickCount(AbstractEffect effect) public int getTickCount(AbstractEffect effect)
{
if (_tasks != null)
{ {
final EffectTaskInfo effectTaskInfo = _tasks.get(effect); final EffectTaskInfo effectTaskInfo = _tasks.get(effect);
if (effectTaskInfo != null) if (effectTaskInfo != null)
{ {
return effectTaskInfo.getEffectTask().getTickCount(); return effectTaskInfo.getEffectTask().getTickCount();
} }
}
return 0; return 0;
} }

View File

@@ -1833,8 +1833,6 @@ public final class Skill implements IIdentifiable
if (_effectTypes == null) if (_effectTypes == null)
{ {
synchronized (this) synchronized (this)
{
if (_effectTypes == null)
{ {
final Set<Byte> effectTypesSet = new HashSet<>(); final Set<Byte> effectTypesSet = new HashSet<>();
for (List<AbstractEffect> effectList : _effectLists.values()) for (List<AbstractEffect> effectList : _effectLists.values())
@@ -1857,7 +1855,6 @@ public final class Skill implements IIdentifiable
_effectTypes = effectTypesArray; _effectTypes = effectTypesArray;
} }
} }
}
if (Arrays.binarySearch(_effectTypes, (byte) effectType.ordinal()) >= 0) if (Arrays.binarySearch(_effectTypes, (byte) effectType.ordinal()) >= 0)
{ {

View File

@@ -130,13 +130,10 @@ public class L2EffectZone extends L2ZoneType
if ((_skills != null) && (getSettings().getTask() == null)) if ((_skills != null) && (getSettings().getTask() == null))
{ {
synchronized (this) synchronized (this)
{
if (getSettings().getTask() == null)
{ {
getSettings().setTask(ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplySkill(), _initialDelay, _reuse)); getSettings().setTask(ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
} }
} }
}
if (!character.isPlayer()) if (!character.isPlayer())
{ {
return; return;
@@ -192,13 +189,10 @@ public class L2EffectZone extends L2ZoneType
if (_skills == null) if (_skills == null)
{ {
synchronized (this) synchronized (this)
{
if (_skills == null)
{ {
_skills = new ConcurrentHashMap<>(3); _skills = new ConcurrentHashMap<>(3);
} }
} }
}
_skills.put(skillId, skillLvL); _skills.put(skillId, skillLvL);
} }