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

@ -257,16 +257,13 @@ public class L2Attackable extends L2Npc
{
synchronized (this)
{
if (_firstCommandChannelAttacked == null)
_firstCommandChannelAttacked = attacker.getParty().getCommandChannel();
if (_firstCommandChannelAttacked != null)
{
_firstCommandChannelAttacked = attacker.getParty().getCommandChannel();
if (_firstCommandChannelAttacked != null)
{
_commandChannelTimer = new CommandChannelTimer(this);
_commandChannelLastAttack = System.currentTimeMillis();
ThreadPoolManager.getInstance().scheduleGeneral(_commandChannelTimer, 10000); // check for last attack
_firstCommandChannelAttacked.broadcastPacket(new CreatureSay(0, ChatType.PARTYROOM_ALL, "", "You have looting rights!")); // TODO: retail msg
}
_commandChannelTimer = new CommandChannelTimer(this);
_commandChannelLastAttack = System.currentTimeMillis();
ThreadPoolManager.getInstance().scheduleGeneral(_commandChannelTimer, 10000); // check for last attack
_firstCommandChannelAttacked.broadcastPacket(new CreatureSay(0, ChatType.PARTYROOM_ALL, "", "You have looting rights!")); // TODO: retail msg
}
}
}

View File

@ -29,6 +29,7 @@ import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
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());
private volatile Set<L2Character> _attackByList;
private volatile Set<L2Character> _attackByList = new CopyOnWriteArraySet<>();
private volatile boolean _isCastingNow = false;
private volatile boolean _isCastingSimultaneouslyNow = false;
private Skill _lastSkillCast;
@ -225,11 +226,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
/** Map containing all skills of this character. */
private final Map<Integer, Skill> _skills = new ConcurrentHashMap<>();
/** 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. */
private volatile Map<Integer, TimeStamp> _reuseTimeStampsItems = null;
private volatile Map<Integer, TimeStamp> _reuseTimeStampsItems = new ConcurrentHashMap<>();
/** 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 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 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. */
private final CharEffectList _effectList = new CharEffectList(this);
/** The character that summons this character. */
@ -258,8 +259,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
private SkillChannelized _channelized = null;
private volatile Set<AbnormalVisualEffect> _abnormalVisualEffects;
private volatile Set<AbnormalVisualEffect> _currentAbnormalVisualEffects;
private volatile Set<AbnormalVisualEffect> _abnormalVisualEffects = new CopyOnWriteArraySet<>();
private volatile Set<AbnormalVisualEffect> _currentAbnormalVisualEffects = new CopyOnWriteArraySet<>();
/** Movement data of this L2Character */
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)
{
if (_reuseTimeStampsItems == null)
{
synchronized (this)
{
if (_reuseTimeStampsItems == null)
{
_reuseTimeStampsItems = new ConcurrentHashMap<>();
}
}
}
_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)
{
final TimeStamp reuseStamp = (_reuseTimeStampsItems != null) ? _reuseTimeStampsItems.get(itemObjId) : null;
final TimeStamp reuseStamp = _reuseTimeStampsItems.get(itemObjId);
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)
{
if ((group > 0) && (_reuseTimeStampsItems != null))
if (group > 0)
{
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)
{
if (_reuseTimeStampsSkills == null)
{
synchronized (this)
{
if (_reuseTimeStampsSkills == null)
{
_reuseTimeStampsSkills = new ConcurrentHashMap<>();
}
}
}
_reuseTimeStampsSkills.put(skill.getReuseHashCode(), new TimeStamp(skill, reuse, systime));
}
@ -2226,10 +2207,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public final synchronized void removeTimeStamp(Skill skill)
{
if (_reuseTimeStampsSkills != null)
{
_reuseTimeStampsSkills.remove(skill.getReuseHashCode());
}
_reuseTimeStampsSkills.remove(skill.getReuseHashCode());
}
/**
@ -2237,10 +2215,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public final synchronized void resetTimeStamps()
{
if (_reuseTimeStampsSkills != null)
{
_reuseTimeStampsSkills.clear();
}
_reuseTimeStampsSkills.clear();
}
/**
@ -2250,7 +2225,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
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;
}
@ -2261,7 +2236,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
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();
}
@ -2272,7 +2247,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
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)
{
if ((skill == null) || (_disabledSkills == null))
if (skill == null)
{
return;
}
@ -2309,18 +2284,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
return;
}
if (_disabledSkills == null)
{
synchronized (this)
{
if (_disabledSkills == null)
{
_disabledSkills = new ConcurrentHashMap<>();
}
}
}
_disabledSkills.put(skill.getReuseHashCode(), delay > 0 ? System.currentTimeMillis() + delay : Long.MAX_VALUE);
}
@ -2329,10 +2292,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public final synchronized void resetDisabledSkills()
{
if (_disabledSkills != null)
{
_disabledSkills.clear();
}
_disabledSkills.clear();
}
/**
@ -2357,7 +2317,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
return true;
}
if (_disabledSkills == null)
if (_disabledSkills.isEmpty())
{
return false;
}
@ -2454,7 +2414,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
getWorldRegion().onDeath(this);
}
getAttackByList().clear();
clearAttackByList();
if (isChannelized())
{
@ -2555,12 +2515,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
synchronized (this)
{
if (_ai == null)
{
// Return the new AI within the synchronized block
// to avoid being nulled by other threads
return _ai = initAI();
}
// Return the new AI within the synchronized block
// to avoid being nulled by other threads
return _ai = initAI();
}
}
return _ai;
@ -2624,19 +2581,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public final Set<L2Character> getAttackByList()
{
if (_attackByList == null)
{
synchronized (this)
{
if (_attackByList == null)
{
_attackByList = ConcurrentHashMap.newKeySet();
}
}
}
return _attackByList;
}
public void clearAttackByList()
{
_attackByList.clear();
}
public final Skill getLastSimultaneousSkillCast()
{
return _lastSimultaneousSkillCast;
@ -3135,12 +3087,12 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
.collect(Collectors.toCollection(HashSet::new));
//@formatter:on
if (_abnormalVisualEffects != null)
if (!_abnormalVisualEffects.isEmpty())
{
abnormalVisualEffects.addAll(_abnormalVisualEffects);
}
if ((_currentAbnormalVisualEffects == null) || !_currentAbnormalVisualEffects.equals(abnormalVisualEffects))
if ((_currentAbnormalVisualEffects.isEmpty()) || !_currentAbnormalVisualEffects.equals(abnormalVisualEffects))
{
_currentAbnormalVisualEffects = abnormalVisualEffects;
updateAbnormalVisualEffects();
@ -3153,7 +3105,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
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)
{
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)
{
if (_abnormalVisualEffects == null)
{
synchronized (this)
{
if (_abnormalVisualEffects == null)
{
_abnormalVisualEffects = Collections.newSetFromMap(new ConcurrentHashMap<>());
}
}
}
_abnormalVisualEffects.add(ave);
}
resetCurrentAbnormalVisualEffects();
@ -3195,14 +3137,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
*/
public final void stopAbnormalVisualEffect(AbnormalVisualEffect... aves)
{
if (_abnormalVisualEffects != null)
for (AbnormalVisualEffect ave : aves)
{
for (AbnormalVisualEffect ave : aves)
{
_abnormalVisualEffects.remove(ave);
}
resetCurrentAbnormalVisualEffects();
_abnormalVisualEffects.remove(ave);
}
resetCurrentAbnormalVisualEffects();
}
/**
@ -4953,16 +4892,14 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
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()))
{
makeTriggerCast(holder.getSkill(), target);
}
makeTriggerCast(holder.getSkill(), target);
}
}
// Launch weapon onCritical Special ability effect if available
if (crit && (weapon != null))
{
@ -5748,14 +5685,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
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()))
{
makeTriggerCast(holder.getSkill(), target);
}
makeTriggerCast(holder.getSkill(), target);
}
}
}
@ -6506,16 +6440,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
public Map<Integer, OptionsSkillHolder> getTriggerSkills()
{
if (_triggerSkills == null)
{
synchronized (this)
{
if (_triggerSkills == null)
{
_triggerSkills = new ConcurrentHashMap<>();
}
}
}
return _triggerSkills;
}
@ -6793,7 +6717,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
public boolean isInvulAgainst(int skillId, int skillLvl)
{
if (_invulAgainst == null)
if (_invulAgainst.isEmpty())
{
return false;
}
@ -6803,16 +6727,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
private Map<Integer, InvulSkillHolder> getInvulAgainstSkills()
{
if (_invulAgainst == null)
{
synchronized (this)
{
if (_invulAgainst == null)
{
_invulAgainst = new ConcurrentHashMap<>();
}
}
}
return _invulAgainst;
}

View File

@ -144,7 +144,7 @@ public class L2Npc extends L2Character
private int _shotsMask = 0;
private int _killingBlowWeaponId;
/** 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.
@ -1685,19 +1685,7 @@ public class L2Npc extends L2Character
*/
public final void addSummonedNpc(L2Npc npc)
{
if (_summonedNpcs == null)
{
synchronized (this)
{
if (_summonedNpcs == null)
{
_summonedNpcs = new ConcurrentHashMap<>();
}
}
}
_summonedNpcs.put(npc.getObjectId(), npc);
npc.setSummoner(this);
}

View File

@ -172,15 +172,12 @@ public class L2ClanHallDoormenInstance extends L2DoormenInstance
{
synchronized (this)
{
if (!_init)
_clanHall = ClanHallManager.getInstance().getNearbyClanHall(getX(), getY(), 500);
if (_clanHall != null)
{
_clanHall = ClanHallManager.getInstance().getNearbyClanHall(getX(), getY(), 500);
if (_clanHall != null)
{
_hasEvolve = Arrays.binarySearch(CH_WITH_EVOLVE, _clanHall.getId()) >= 0;
}
_init = true;
_hasEvolve = Arrays.binarySearch(CH_WITH_EVOLVE, _clanHall.getId()) >= 0;
}
_init = true;
}
}
return _clanHall;

View File

@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
*/
public class L2ControlTowerInstance extends L2Tower
{
private volatile List<L2Spawn> _guards;
private volatile List<L2Spawn> _guards = new CopyOnWriteArrayList<>();
/**
* Creates a control tower.
@ -50,22 +50,19 @@ public class L2ControlTowerInstance extends L2Tower
{
getCastle().getSiege().killedCT(this);
if ((_guards != null) && !_guards.isEmpty())
for (L2Spawn spawn : _guards)
{
for (L2Spawn spawn : _guards)
try
{
try
{
spawn.stopRespawn();
// spawn.getLastSpawn().doDie(spawn.getLastSpawn());
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error at L2ControlTowerInstance", e);
}
spawn.stopRespawn();
// spawn.getLastSpawn().doDie(spawn.getLastSpawn());
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error at L2ControlTowerInstance", e);
}
_guards.clear();
}
_guards.clear();
}
return super.doDie(killer);
}
@ -77,16 +74,6 @@ public class L2ControlTowerInstance extends L2Tower
private final List<L2Spawn> getGuards()
{
if (_guards == null)
{
synchronized (this)
{
if (_guards == null)
{
_guards = new CopyOnWriteArrayList<>();
}
}
}
return _guards;
}
}

View File

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

View File

@ -518,7 +518,7 @@ public final class L2PcInstance extends L2Playable
private long _offlineShopStart = 0;
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 */
private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new ConcurrentHashMap<>();
@ -607,7 +607,7 @@ public final class L2PcInstance extends L2Playable
/** The Pet of the L2PcInstance */
private L2Summon _pet = null;
/** Servitors of the L2PcInstance */
private volatile Map<Integer, L2Summon> _servitors = null;
private volatile Map<Integer, L2Summon> _servitors = new ConcurrentHashMap<>();
private int _usedSummonPoints = 0;
/** The L2Decoy of the L2PcInstance */
private L2Decoy _decoy = null;
@ -693,7 +693,7 @@ public final class L2PcInstance extends L2Playable
private L2ItemInstance _lure = null;
private volatile Map<Integer, ExResponseCommissionInfo> _lastCommissionInfos;
private volatile Map<Integer, ExResponseCommissionInfo> _lastCommissionInfos = new ConcurrentHashMap<>();
public boolean isSpawnProtected()
{
@ -722,7 +722,7 @@ public final class L2PcInstance extends L2Playable
private int _expertiseWeaponPenalty = 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;
/** 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 */
private volatile List<QuestState> _notifyQuestOfDeathList;
private volatile List<QuestState> _notifyQuestOfDeathList = new CopyOnWriteArrayList<>();
/**
* 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)
{
if ((qs == null) || (_notifyQuestOfDeathList == null))
if (qs == null)
{
return;
}
_notifyQuestOfDeathList.remove(qs);
}
@ -1572,23 +1571,12 @@ public final class L2PcInstance extends L2Playable
*/
public final List<QuestState> getNotifyQuestOfDeath()
{
if (_notifyQuestOfDeathList == null)
{
synchronized (this)
{
if (_notifyQuestOfDeathList == null)
{
_notifyQuestOfDeathList = new CopyOnWriteArrayList<>();
}
}
}
return _notifyQuestOfDeathList;
}
public final boolean isNotifyQuestOfDeathEmpty()
{
return (_notifyQuestOfDeathList == null) || _notifyQuestOfDeathList.isEmpty();
return _notifyQuestOfDeathList.isEmpty();
}
/**
@ -5755,7 +5743,7 @@ public final class L2PcInstance extends L2Playable
@Override
public Map<Integer, L2Summon> getServitors()
{
return _servitors == null ? Collections.emptyMap() : _servitors;
return _servitors;
}
public L2Summon getAnyServitor()
@ -5796,16 +5784,6 @@ public final class L2PcInstance extends L2Playable
public void addServitor(L2Summon servitor)
{
if (_servitors == null)
{
synchronized (this)
{
if (_servitors == null)
{
_servitors = new ConcurrentHashMap<>(1);
}
}
}
_servitors.put(servitor.getObjectId(), servitor);
}
@ -6036,10 +6014,7 @@ public final class L2PcInstance extends L2Playable
{
synchronized (this)
{
if (_manufactureItems == null)
{
_manufactureItems = Collections.synchronizedMap(new LinkedHashMap<Integer, L2ManufactureItem>());
}
_manufactureItems = Collections.synchronizedMap(new LinkedHashMap<Integer, L2ManufactureItem>());
}
}
return _manufactureItems;
@ -11065,10 +11040,7 @@ public final class L2PcInstance extends L2Playable
{
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);
}
}
}
@ -12814,16 +12786,6 @@ public final class L2PcInstance extends L2Playable
public void addTransformSkill(Skill sk)
{
if (_transformSkills == null)
{
synchronized (this)
{
if (_transformSkills == null)
{
_transformSkills = new ConcurrentHashMap<>();
}
}
}
_transformSkills.put(sk.getId(), sk);
if (sk.isPassive())
{
@ -12833,17 +12795,17 @@ public final class L2PcInstance extends L2Playable
public Skill getTransformSkill(int id)
{
return _transformSkills == null ? null : _transformSkills.get(id);
return _transformSkills.get(id);
}
public boolean hasTransformSkill(int id)
{
return (_transformSkills != null) && _transformSkills.containsKey(id);
return _transformSkills.containsKey(id);
}
public void removeAllTransformSkills()
{
_transformSkills = null;
_transformSkills.clear();
}
protected void startFeed(int npcId)
@ -13076,10 +13038,7 @@ public final class L2PcInstance extends L2Playable
{
synchronized (this)
{
if (_chargeTask != null)
{
_chargeTask.cancel(false);
}
_chargeTask.cancel(false);
}
}
_chargeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ResetChargesTask(this), 600000);
@ -14946,22 +14905,12 @@ public final class L2PcInstance extends L2Playable
*/
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);
}
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)
{
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)
{
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()
{
return (_requests != null) && !_requests.isEmpty();
return !_requests.isEmpty();
}
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
public final boolean hasRequest(Class<? extends AbstractRequest> requestClass, Class<? extends AbstractRequest>... classes)
{
if (_requests == null)
if (_requests.isEmpty())
{
return false;
}
@ -15024,7 +14973,7 @@ public final class L2PcInstance extends L2Playable
*/
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));
}
/**
@ -15033,10 +14982,7 @@ public final class L2PcInstance extends L2Playable
*/
public void removeRequestsThatProcessesItem(int objectId)
{
if (_requests != null)
{
_requests.values().removeIf(req -> req.isUsing(objectId));
}
_requests.values().removeIf(req -> req.isUsing(objectId));
}
/*
@ -15095,16 +15041,6 @@ public final class L2PcInstance extends L2Playable
*/
public Map<Integer, ExResponseCommissionInfo> getLastCommissionInfos()
{
if (_lastCommissionInfos == null)
{
synchronized (this)
{
if (_lastCommissionInfos == null)
{
_lastCommissionInfos = new ConcurrentHashMap<>();
}
}
}
return _lastCommissionInfos;
}

View File

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

View File

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