Fixed SummonEffectTable concurrency problem.
This commit is contained in:
@ -16,9 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.data.sql.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
@ -33,16 +33,16 @@ public class SummonEffectsTable
|
||||
// -> key: charObjectId, value: classIndex Map
|
||||
// --> key: classIndex, value: servitors Map
|
||||
// ---> 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return null;
|
||||
@ -51,9 +51,9 @@ public class SummonEffectsTable
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
@ -19,11 +19,12 @@ package org.l2jmobius.gameserver.model.actor.instance;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -901,7 +902,7 @@ public class PetInstance extends Summon
|
||||
public void stopSkillEffects(boolean removed, int 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())
|
||||
{
|
||||
for (SummonEffect effect : effects)
|
||||
@ -1049,7 +1050,7 @@ public class PetInstance extends Summon
|
||||
ps2.setInt(6, ++buff_index);
|
||||
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();
|
||||
}
|
||||
@ -1084,7 +1085,7 @@ public class PetInstance extends Summon
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,8 @@ import java.sql.ResultSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -237,10 +235,10 @@ public class ServitorInstance extends Summon implements Runnable
|
||||
public void stopSkillEffects(boolean removed, int 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)
|
||||
{
|
||||
final List<SummonEffect> effects = servitorEffects.get(_referenceSkill);
|
||||
final Collection<SummonEffect> effects = servitorEffects.get(_referenceSkill);
|
||||
if ((effects != null) && !effects.isEmpty())
|
||||
{
|
||||
for (SummonEffect effect : effects)
|
||||
@ -373,7 +371,7 @@ public class ServitorInstance extends Summon implements Runnable
|
||||
}
|
||||
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()));
|
||||
@ -430,7 +428,7 @@ public class ServitorInstance extends Summon implements Runnable
|
||||
}
|
||||
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));
|
||||
|
Reference in New Issue
Block a user