Fixed SummonEffectTable concurrency problem.

This commit is contained in:
MobiusDevelopment 2019-11-18 02:32:55 +00:00
parent 4d04017769
commit 2d19e0b2a1
47 changed files with 281 additions and 300 deletions

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,12 +16,10 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.ArrayList; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance; import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
@ -39,11 +37,11 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
private Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) private Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,7 +49,7 @@ public class SummonEffectsTable
return servitorMap.get(owner.getClassIndex()); return servitorMap.get(owner.getClassIndex());
} }
private List<SummonEffect> getServitorEffects(PlayerInstance owner, int referenceSkill) private Collection<SummonEffect> getServitorEffects(PlayerInstance owner, int referenceSkill)
{ {
return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null; return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null;
} }
@ -61,7 +59,7 @@ public class SummonEffectsTable
return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex()); return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex());
} }
private void removeEffects(List<SummonEffect> effects, int skillId) private void removeEffects(Collection<SummonEffect> effects, int skillId)
{ {
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
@ -76,7 +74,7 @@ public class SummonEffectsTable
} }
} }
private void applyEffects(Summon summon, List<SummonEffect> summonEffects) private void applyEffects(Summon summon, Collection<SummonEffect> summonEffects)
{ {
if (summonEffects == null) if (summonEffects == null)
{ {
@ -107,9 +105,9 @@ public class SummonEffectsTable
public void addServitorEffect(PlayerInstance owner, int referenceSkill, Skill skill, int effectCurTime) public void addServitorEffect(PlayerInstance owner, int referenceSkill, Skill skill, int effectCurTime)
{ {
_servitorEffects.putIfAbsent(owner.getObjectId(), new HashMap<>()); _servitorEffects.putIfAbsent(owner.getObjectId(), new ConcurrentHashMap<>());
_servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new HashMap<>()); _servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new ConcurrentHashMap<>());
getServitorEffects(owner).putIfAbsent(referenceSkill, new CopyOnWriteArrayList<>()); getServitorEffects(owner).putIfAbsent(referenceSkill, ConcurrentHashMap.newKeySet());
getServitorEffects(owner).get(referenceSkill).add(new SummonEffect(skill, effectCurTime)); getServitorEffects(owner).get(referenceSkill).add(new SummonEffect(skill, effectCurTime));
} }
@ -124,11 +122,11 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime) public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime)
{ {
_petEffects.computeIfAbsent(controlObjectId, k -> new ArrayList<>()).add(new SummonEffect(skill, effectCurTime)); _petEffects.computeIfAbsent(controlObjectId, k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
public boolean containsPetId(int controlObjectId) public boolean containsPetId(int controlObjectId)

View File

@ -16,12 +16,10 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.ArrayList; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance; import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
@ -39,11 +37,11 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
private Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) private Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,7 +49,7 @@ public class SummonEffectsTable
return servitorMap.get(owner.getClassIndex()); return servitorMap.get(owner.getClassIndex());
} }
private List<SummonEffect> getServitorEffects(PlayerInstance owner, int referenceSkill) private Collection<SummonEffect> getServitorEffects(PlayerInstance owner, int referenceSkill)
{ {
return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null; return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null;
} }
@ -61,7 +59,7 @@ public class SummonEffectsTable
return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex()); return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex());
} }
private void removeEffects(List<SummonEffect> effects, int skillId) private void removeEffects(Collection<SummonEffect> effects, int skillId)
{ {
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
@ -76,7 +74,7 @@ public class SummonEffectsTable
} }
} }
private void applyEffects(Summon summon, List<SummonEffect> summonEffects) private void applyEffects(Summon summon, Collection<SummonEffect> summonEffects)
{ {
if (summonEffects == null) if (summonEffects == null)
{ {
@ -107,9 +105,9 @@ public class SummonEffectsTable
public void addServitorEffect(PlayerInstance owner, int referenceSkill, Skill skill, int effectCurTime) public void addServitorEffect(PlayerInstance owner, int referenceSkill, Skill skill, int effectCurTime)
{ {
_servitorEffects.putIfAbsent(owner.getObjectId(), new HashMap<>()); _servitorEffects.putIfAbsent(owner.getObjectId(), new ConcurrentHashMap<>());
_servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new HashMap<>()); _servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new ConcurrentHashMap<>());
getServitorEffects(owner).putIfAbsent(referenceSkill, new CopyOnWriteArrayList<>()); getServitorEffects(owner).putIfAbsent(referenceSkill, ConcurrentHashMap.newKeySet());
getServitorEffects(owner).get(referenceSkill).add(new SummonEffect(skill, effectCurTime)); getServitorEffects(owner).get(referenceSkill).add(new SummonEffect(skill, effectCurTime));
} }
@ -124,11 +122,11 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime) public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime)
{ {
_petEffects.computeIfAbsent(controlObjectId, k -> new ArrayList<>()).add(new SummonEffect(skill, effectCurTime)); _petEffects.computeIfAbsent(controlObjectId, k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
public boolean containsPetId(int controlObjectId) public boolean containsPetId(int controlObjectId)

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -901,7 +902,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));

View File

@ -16,9 +16,9 @@
*/ */
package org.l2jmobius.gameserver.data.sql.impl; package org.l2jmobius.gameserver.data.sql.impl;
import java.util.HashMap; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@ -33,16 +33,16 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> _servitorEffects = new ConcurrentHashMap<>();
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner() public Map<Integer, Map<Integer, Map<Integer, Collection<SummonEffect>>>> getServitorEffectsOwner()
{ {
return _servitorEffects; return _servitorEffects;
} }
public Map<Integer, List<SummonEffect>> getServitorEffects(PlayerInstance owner) public Map<Integer, Collection<SummonEffect>> getServitorEffects(PlayerInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Collection<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@ -51,9 +51,9 @@ public class SummonEffectsTable
} }
/** Pets **/ /** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list private final Map<Integer, Collection<SummonEffect>> _petEffects = new ConcurrentHashMap<>(); // key: petItemObjectId, value: Effects list
public Map<Integer, List<SummonEffect>> getPetEffects() public Map<Integer, Collection<SummonEffect>> getPetEffects()
{ {
return _petEffects; return _petEffects;
} }

View File

@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -899,7 +900,7 @@ public class PetInstance extends Summon
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()); final Collection<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -1047,7 +1048,7 @@ public class PetInstance extends Summon
ps2.setInt(6, ++buff_index); ps2.setInt(6, ++buff_index);
ps2.addBatch(); ps2.addBatch();
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, info.getTime()));
} }
ps2.executeBatch(); ps2.executeBatch();
} }
@ -1082,7 +1083,7 @@ public class PetInstance extends Summon
if (skill.hasEffects(EffectScope.GENERAL)) if (skill.hasEffects(EffectScope.GENERAL))
{ {
SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> new CopyOnWriteArrayList<>()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getPetEffects().computeIfAbsent(getControlObjectId(), k -> ConcurrentHashMap.newKeySet()).add(new SummonEffect(skill, effectCurTime));
} }
} }
} }

View File

@ -22,10 +22,8 @@ import java.sql.ResultSet;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
public void stopSkillEffects(boolean removed, int skillId) public void stopSkillEffects(boolean removed, int skillId)
{ {
super.stopSkillEffects(removed, skillId); super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner()); final Map<Integer, Collection<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null) if (servitorEffects != null)
{ {
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill); final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
if ((effects != null) && !effects.isEmpty()) if ((effects != null) && !effects.isEmpty())
{ {
for (SummonEffect effect : effects) for (SummonEffect effect : effects)
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime())); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, info.getTime()));
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
} }
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<>()); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), ConcurrentHashMap.newKeySet());
} }
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime)); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(new SummonEffect(skill, effectCurTime));