Sync with L2jServer HighFive Apr 1st 2015.

This commit is contained in:
MobiusDev
2015-04-02 04:12:06 +00:00
parent 8300183361
commit 1abccfcae0
26 changed files with 283 additions and 248 deletions

View File

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

View File

@ -21,8 +21,6 @@ package com.l2jserver.gameserver.model.actor.instance;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Future;
@ -35,7 +33,6 @@ import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
import com.l2jserver.gameserver.data.sql.impl.SummonEffectsTable;
import com.l2jserver.gameserver.data.sql.impl.SummonEffectsTable.SummonEffect;
import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.datatables.SkillData;
@ -928,17 +925,7 @@ public class L2PetInstance extends L2Summon
public final void stopSkillEffects(boolean removed, int skillId)
{
super.stopSkillEffects(removed, skillId);
List<SummonEffect> effects = SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId());
if ((effects != null) && !effects.isEmpty())
{
for (SummonEffect effect : effects)
{
if (effect.getSkill().getId() == skillId)
{
SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).remove(effect);
}
}
}
SummonEffectsTable.getInstance().removePetEffects(getControlObjectId(), skillId);
}
@Override
@ -1013,7 +1000,7 @@ public class L2PetInstance extends L2Summon
}
// Clear list for overwrite
SummonEffectsTable.getInstance().getPetEffects().getOrDefault(getControlObjectId(), Collections.emptyList()).clear();
SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
@ -1069,8 +1056,7 @@ public class L2PetInstance extends L2Summon
ps2.setInt(5, ++buff_index);
ps2.execute();
SummonEffectsTable.getInstance().getPetEffects().putIfAbsent(getControlObjectId(), new ArrayList<>());
SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, info.getTime()));
SummonEffectsTable.getInstance().addPetEffect(getControlObjectId(), skill, info.getTime());
}
}
}
@ -1087,7 +1073,7 @@ public class L2PetInstance extends L2Summon
PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
{
if (!SummonEffectsTable.getInstance().getPetEffects().containsKey(getControlObjectId()))
if (!SummonEffectsTable.getInstance().containsPetId(getControlObjectId()))
{
ps1.setInt(1, getControlObjectId());
try (ResultSet rset = ps1.executeQuery())
@ -1104,12 +1090,7 @@ public class L2PetInstance extends L2Summon
if (skill.hasEffects(EffectScope.GENERAL))
{
if (!SummonEffectsTable.getInstance().getPetEffects().containsKey(getControlObjectId()))
{
SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new ArrayList<>());
}
SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effectCurTime));
SummonEffectsTable.getInstance().addPetEffect(getControlObjectId(), skill, effectCurTime);
}
}
}
@ -1124,18 +1105,7 @@ public class L2PetInstance extends L2Summon
}
finally
{
if (SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()) == null)
{
return;
}
for (SummonEffect se : SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()))
{
if (se != null)
{
se.getSkill().applyEffects(this, this, false, se.getEffectCurTime());
}
}
SummonEffectsTable.getInstance().applyPetEffects(this, getControlObjectId());
}
}

View File

@ -21,12 +21,8 @@ package com.l2jserver.gameserver.model.actor.instance;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -36,7 +32,6 @@ import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
import com.l2jserver.gameserver.data.sql.impl.SummonEffectsTable;
import com.l2jserver.gameserver.data.sql.impl.SummonEffectsTable.SummonEffect;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.enums.InstanceType;
import com.l2jserver.gameserver.model.L2Object;
@ -231,22 +226,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
public final void stopSkillEffects(boolean removed, int skillId)
{
super.stopSkillEffects(removed, skillId);
final Map<Integer, List<SummonEffect>> servitorEffects = SummonEffectsTable.getInstance().getServitorEffects(getOwner());
if (servitorEffects != null)
{
final List<SummonEffect> effects = servitorEffects.get(getReferenceSkill());
if ((effects != null) && !effects.isEmpty())
{
for (SummonEffect effect : effects)
{
final Skill skill = effect.getSkill();
if ((skill != null) && (skill.getId() == skillId))
{
effects.remove(effect);
}
}
}
}
SummonEffectsTable.getInstance().removeServitorEffects(getOwner(), getReferenceSkill(), skillId);
}
@Override
@ -277,10 +257,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
}
// Clear list for overwrite
if (SummonEffectsTable.getInstance().getServitorEffectsOwner().getOrDefault(getOwner().getObjectId(), Collections.emptyMap()).containsKey(getOwner().getClassIndex()))
{
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).getOrDefault(getReferenceSkill(), Collections.emptyList()).clear();
}
SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
@ -341,21 +318,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
ps2.setInt(7, ++buff_index);
ps2.execute();
// XXX: Rework me!
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()))
{
SummonEffectsTable.getInstance().getServitorEffectsOwner().put(getOwner().getObjectId(), new HashMap<Integer, Map<Integer, List<SummonEffect>>>());
}
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()))
{
SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).put(getOwner().getClassIndex(), new HashMap<Integer, List<SummonEffect>>());
}
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<SummonEffect>());
}
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, info.getTime()));
SummonEffectsTable.getInstance().addServitorEffect(getOwner(), getReferenceSkill(), skill, info.getTime());
}
}
}
@ -376,7 +339,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()) || !SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()) || !SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
{
try (PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
{
@ -395,23 +358,9 @@ public class L2ServitorInstance extends L2Summon implements Runnable
continue;
}
// XXX: Rework me!
if (skill.hasEffects(EffectScope.GENERAL))
{
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()))
{
SummonEffectsTable.getInstance().getServitorEffectsOwner().put(getOwner().getObjectId(), new HashMap<Integer, Map<Integer, List<SummonEffect>>>());
}
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()))
{
SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).put(getOwner().getClassIndex(), new HashMap<Integer, List<SummonEffect>>());
}
if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new CopyOnWriteArrayList<SummonEffect>());
}
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effectCurTime));
SummonEffectsTable.getInstance().addServitorEffect(getOwner(), getReferenceSkill(), skill, effectCurTime);
}
}
}
@ -432,18 +381,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
}
finally
{
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()) || !SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()) || !SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{
return;
}
for (SummonEffect se : SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()))
{
if (se != null)
{
se.getSkill().applyEffects(this, this, false, se.getEffectCurTime());
}
}
SummonEffectsTable.getInstance().applyServitorEffects(this, getOwner(), getReferenceSkill());
}
}

View File

@ -160,13 +160,13 @@ public final class EventDispatcher
*/
private <T extends AbstractEventReturn> T notifyEventToMultipleContainers(IBaseEvent event, ListenersContainer[] containers, Class<T> callbackClass)
{
if (event == null)
{
throw new NullPointerException("Event cannot be null!");
}
try
{
if (event == null)
{
throw new NullPointerException("Event cannot be null!");
}
T callback = null;
if (containers != null)
{