Sync with L2jServer HighFive Apr 1st 2015.
This commit is contained in:
@ -155,7 +155,7 @@ import com.l2jserver.status.Status;
|
||||
import com.l2jserver.util.DeadLockDetector;
|
||||
import com.l2jserver.util.IPv4Filter;
|
||||
|
||||
public class GameServer
|
||||
public final class GameServer
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(GameServer.class.getName());
|
||||
|
||||
|
@ -200,7 +200,7 @@ public class GeoData
|
||||
return z;
|
||||
}
|
||||
|
||||
int nextLowerZ = getNextLowerZ(geoX, geoY, z + 100);
|
||||
int nextLowerZ = getNextLowerZ(geoX, geoY, z + 20);
|
||||
return Math.abs(nextLowerZ - z) <= SPAWN_Z_DELTA_LIMIT ? nextLowerZ : z;
|
||||
}
|
||||
|
||||
|
@ -91,15 +91,18 @@ public class HtmCache
|
||||
private void parseDir(File dir)
|
||||
{
|
||||
final File[] files = dir.listFiles();
|
||||
for (File file : files)
|
||||
if (files != null)
|
||||
{
|
||||
if (!file.isDirectory())
|
||||
for (File file : files)
|
||||
{
|
||||
loadFile(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
parseDir(file);
|
||||
if (!file.isDirectory())
|
||||
{
|
||||
loadFile(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
parseDir(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,14 +106,21 @@ public class PostBBSManager extends BaseBBSManager
|
||||
|
||||
private void showEditPost(Topic topic, Forum forum, L2PcInstance activeChar, int idp)
|
||||
{
|
||||
Post p = getGPosttByTopic(topic);
|
||||
if ((forum == null) || (topic == null) || (p == null))
|
||||
if (topic == null)
|
||||
{
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>Error, this forum, topic or post does not exit !</center><br><br></body></html>", activeChar);
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>Error: This topic does not exist!</center></body></html>", activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
showHtmlEditPost(topic, activeChar, forum, p);
|
||||
final Post p = getGPosttByTopic(topic);
|
||||
if ((forum == null) || (p == null))
|
||||
{
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>Error: This forum or post does not exist!</center></body></html>", activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
showHtmlEditPost(topic, activeChar, forum, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +128,7 @@ public class PostBBSManager extends BaseBBSManager
|
||||
{
|
||||
if ((forum == null) || (topic == null))
|
||||
{
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>Error, this forum is not implemented yet</center><br><br></body></html>", activeChar);
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>Error: This forum is not implemented yet!</center></body></html>", activeChar);
|
||||
}
|
||||
else if (forum.getType() == Forum.MEMO)
|
||||
{
|
||||
@ -129,7 +136,7 @@ public class PostBBSManager extends BaseBBSManager
|
||||
}
|
||||
else
|
||||
{
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>the forum: " + forum.getName() + " is not implemented yet</center><br><br></body></html>", activeChar);
|
||||
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>The forum: " + forum.getName() + " is not implemented yet!</center></body></html>", activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +149,6 @@ public class PostBBSManager extends BaseBBSManager
|
||||
|
||||
private void showMemoPost(Topic topic, L2PcInstance activeChar, Forum forum)
|
||||
{
|
||||
//
|
||||
Post p = getGPosttByTopic(topic);
|
||||
Locale locale = Locale.getDefault();
|
||||
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
|
||||
|
@ -18,11 +18,17 @@
|
||||
*/
|
||||
package com.l2jserver.gameserver.data.sql.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
@ -37,12 +43,7 @@ public class SummonEffectsTable
|
||||
// ---> key: servitorSkillId, value: Effects list
|
||||
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>();
|
||||
|
||||
public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner()
|
||||
{
|
||||
return _servitorEffects;
|
||||
}
|
||||
|
||||
public Map<Integer, List<SummonEffect>> getServitorEffects(L2PcInstance owner)
|
||||
private Map<Integer, List<SummonEffect>> getServitorEffects(L2PcInstance owner)
|
||||
{
|
||||
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
|
||||
if (servitorMap == null)
|
||||
@ -52,15 +53,107 @@ public class SummonEffectsTable
|
||||
return servitorMap.get(owner.getClassIndex());
|
||||
}
|
||||
|
||||
private List<SummonEffect> getServitorEffects(L2PcInstance owner, int referenceSkill)
|
||||
{
|
||||
return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null;
|
||||
}
|
||||
|
||||
private boolean containsOwner(L2PcInstance owner)
|
||||
{
|
||||
return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex());
|
||||
}
|
||||
|
||||
private void removeEffects(List<SummonEffect> effects, int skillId)
|
||||
{
|
||||
if ((effects != null) && !effects.isEmpty())
|
||||
{
|
||||
for (SummonEffect effect : effects)
|
||||
{
|
||||
final Skill skill = effect.getSkill();
|
||||
if ((skill != null) && (skill.getId() == skillId))
|
||||
{
|
||||
effects.remove(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyEffects(L2Summon summon, List<SummonEffect> summonEffects)
|
||||
{
|
||||
if (summonEffects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (SummonEffect se : summonEffects)
|
||||
{
|
||||
if (se != null)
|
||||
{
|
||||
se.getSkill().applyEffects(summon, summon, false, se.getEffectCurTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsSkill(L2PcInstance owner, int referenceSkill)
|
||||
{
|
||||
return containsOwner(owner) && getServitorEffects(owner).containsKey(referenceSkill);
|
||||
}
|
||||
|
||||
public void clearServitorEffects(L2PcInstance owner, int referenceSkill)
|
||||
{
|
||||
if (containsOwner(owner))
|
||||
{
|
||||
|
||||
getServitorEffects(owner).getOrDefault(referenceSkill, Collections.emptyList()).clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void addServitorEffect(L2PcInstance owner, int referenceSkill, Skill skill, int effectCurTime)
|
||||
{
|
||||
_servitorEffects.putIfAbsent(owner.getObjectId(), new HashMap<Integer, Map<Integer, List<SummonEffect>>>());
|
||||
_servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new HashMap<Integer, List<SummonEffect>>());
|
||||
getServitorEffects(owner).putIfAbsent(referenceSkill, new CopyOnWriteArrayList<SummonEffect>());
|
||||
getServitorEffects(owner).get(referenceSkill).add(new SummonEffect(skill, effectCurTime));
|
||||
}
|
||||
|
||||
public void removeServitorEffects(L2PcInstance owner, int referenceSkill, int skillId)
|
||||
{
|
||||
removeEffects(getServitorEffects(owner, referenceSkill), skillId);
|
||||
}
|
||||
|
||||
public void applyServitorEffects(L2ServitorInstance l2ServitorInstance, L2PcInstance owner, int referenceSkill)
|
||||
{
|
||||
applyEffects(l2ServitorInstance, getServitorEffects(owner, referenceSkill));
|
||||
}
|
||||
|
||||
/** Pets **/
|
||||
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list
|
||||
|
||||
public Map<Integer, List<SummonEffect>> getPetEffects()
|
||||
public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime)
|
||||
{
|
||||
return _petEffects;
|
||||
_petEffects.putIfAbsent(controlObjectId, new ArrayList<>()).add(new SummonEffect(skill, effectCurTime));
|
||||
}
|
||||
|
||||
public class SummonEffect
|
||||
public boolean containsPetId(int controlObjectId)
|
||||
{
|
||||
return _petEffects.containsKey(controlObjectId);
|
||||
}
|
||||
|
||||
public void applyPetEffects(L2PetInstance l2PetInstance, int controlObjectId)
|
||||
{
|
||||
applyEffects(l2PetInstance, _petEffects.get(controlObjectId));
|
||||
}
|
||||
|
||||
public void clearPetEffects(int controlObjectId)
|
||||
{
|
||||
_petEffects.getOrDefault(controlObjectId, Collections.emptyList()).clear();
|
||||
}
|
||||
|
||||
public void removePetEffects(int controlObjectId, int skillId)
|
||||
{
|
||||
removeEffects(_petEffects.get(controlObjectId), skillId);
|
||||
}
|
||||
|
||||
private class SummonEffect
|
||||
{
|
||||
Skill _skill;
|
||||
int _effectCurTime;
|
||||
|
@ -69,10 +69,14 @@ public class DocumentEngine
|
||||
_log.warning("Dir " + dir.getAbsolutePath() + " not exists");
|
||||
return;
|
||||
}
|
||||
File[] files = dir.listFiles(new XMLFilter());
|
||||
for (File f : files)
|
||||
|
||||
final File[] files = dir.listFiles(new XMLFilter());
|
||||
if (files != null)
|
||||
{
|
||||
hash.add(f);
|
||||
for (File f : files)
|
||||
{
|
||||
hash.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public final class DuelManager
|
||||
|
||||
public void removeDuel(Duel duel)
|
||||
{
|
||||
_duels.remove(duel);
|
||||
_duels.remove(duel.getId());
|
||||
}
|
||||
|
||||
public void doSurrender(L2PcInstance player)
|
||||
|
@ -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()
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public final class RequestDuelStart extends L2GameClientPacket
|
||||
if (_partyDuel == 1)
|
||||
{
|
||||
// Player must be in a party & the party leader
|
||||
if (!activeChar.isInParty() || !(activeChar.isInParty() && activeChar.getParty().isLeader(activeChar)))
|
||||
if (!activeChar.isInParty() || !activeChar.getParty().isLeader(activeChar))
|
||||
{
|
||||
activeChar.sendMessage("You have to be the leader of a party in order to request a party duel.");
|
||||
return;
|
||||
|
@ -67,7 +67,7 @@ public class RequestSetCastleSiegeTime extends L2GameClientPacket
|
||||
_log.log(Level.WARNING, getType() + ": activeChar: " + activeChar + " castle: " + castle + " castleId: " + _castleId + " is trying to change siege date but is not clan leader!");
|
||||
return;
|
||||
}
|
||||
else if (!castle.getIsTimeRegistrationOver() && !castle.getIsTimeRegistrationOver())
|
||||
else if (!castle.getIsTimeRegistrationOver())
|
||||
{
|
||||
if (isSiegeTimeValid(castle.getSiegeDate().getTimeInMillis(), _time))
|
||||
{
|
||||
|
@ -19,9 +19,8 @@
|
||||
package com.l2jserver.gameserver.pathfinding.cellnodes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -186,8 +185,6 @@ public class CellPathFinding extends PathFinding
|
||||
_postFilterPlayableUses++;
|
||||
}
|
||||
|
||||
int currentX, currentY, currentZ;
|
||||
ListIterator<AbstractNodeLoc> middlePoint, endPoint;
|
||||
boolean remove;
|
||||
int pass = 0;
|
||||
do
|
||||
@ -196,19 +193,18 @@ public class CellPathFinding extends PathFinding
|
||||
_postFilterPasses++;
|
||||
|
||||
remove = false;
|
||||
middlePoint = path.listIterator();
|
||||
endPoint = path.listIterator(1);
|
||||
currentX = x;
|
||||
currentY = y;
|
||||
currentZ = z;
|
||||
final Iterator<AbstractNodeLoc> endPoint = path.iterator();
|
||||
int currentX = x;
|
||||
int currentY = y;
|
||||
int currentZ = z;
|
||||
|
||||
while (endPoint.hasNext())
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
{
|
||||
AbstractNodeLoc locMiddle = path.get(i);
|
||||
AbstractNodeLoc locEnd = endPoint.next();
|
||||
AbstractNodeLoc locMiddle = middlePoint.next();
|
||||
if (GeoData.getInstance().canMove(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
|
||||
{
|
||||
middlePoint.remove();
|
||||
path.remove(i);
|
||||
remove = true;
|
||||
if (debug)
|
||||
{
|
||||
@ -228,11 +224,7 @@ public class CellPathFinding extends PathFinding
|
||||
|
||||
if (debug)
|
||||
{
|
||||
middlePoint = path.listIterator();
|
||||
while (middlePoint.hasNext())
|
||||
{
|
||||
dropDebugItem(65, 1, middlePoint.next());
|
||||
}
|
||||
path.forEach(n -> dropDebugItem(65, 1, n));
|
||||
}
|
||||
|
||||
_findSuccess++;
|
||||
@ -242,7 +234,7 @@ public class CellPathFinding extends PathFinding
|
||||
|
||||
private List<AbstractNodeLoc> constructPath(AbstractNode node)
|
||||
{
|
||||
final LinkedList<AbstractNodeLoc> path = new LinkedList<>();
|
||||
final List<AbstractNodeLoc> path = new CopyOnWriteArrayList<>();
|
||||
int previousDirectionX = Integer.MIN_VALUE;
|
||||
int previousDirectionY = Integer.MIN_VALUE;
|
||||
int directionX, directionY;
|
||||
@ -276,7 +268,7 @@ public class CellPathFinding extends PathFinding
|
||||
previousDirectionX = directionX;
|
||||
previousDirectionY = directionY;
|
||||
|
||||
path.addFirst(node.getLoc());
|
||||
path.add(0, node.getLoc());
|
||||
node.setLoc(null);
|
||||
}
|
||||
|
||||
@ -349,7 +341,7 @@ public class CellPathFinding extends PathFinding
|
||||
{
|
||||
final int mapSize;
|
||||
final int count;
|
||||
ArrayList<CellNodeBuffer> bufs;
|
||||
List<CellNodeBuffer> bufs;
|
||||
int uses = 0;
|
||||
int playableUses = 0;
|
||||
int overflows = 0;
|
||||
|
@ -48,15 +48,18 @@ public class FaenorScriptEngine extends ScriptEngine
|
||||
{
|
||||
final File packDirectory = new File(Config.DATAPACK_ROOT, PACKAGE_DIRECTORY);
|
||||
final File[] files = packDirectory.listFiles(new XMLFilter());
|
||||
for (File file : files)
|
||||
if (files != null)
|
||||
{
|
||||
try (InputStream in = new FileInputStream(file))
|
||||
for (File file : files)
|
||||
{
|
||||
parseScript(new ScriptDocument(file.getName(), in), null);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.log(Level.WARNING, e.getMessage(), e);
|
||||
try (InputStream in = new FileInputStream(file))
|
||||
{
|
||||
parseScript(new ScriptDocument(file.getName(), in), null);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,13 @@ public final class L2ScriptEngineManager
|
||||
{
|
||||
if (dir.isDirectory())
|
||||
{
|
||||
for (File file : dir.listFiles())
|
||||
final File[] files = dir.listFiles();
|
||||
if (files == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
if (file.isDirectory() && recurseDown && (maxDepth > currentDepth))
|
||||
{
|
||||
|
@ -327,21 +327,21 @@ public class LoginController
|
||||
_bannedIps.putIfAbsent(address, System.currentTimeMillis() + duration);
|
||||
}
|
||||
|
||||
public boolean isBannedAddress(InetAddress address)
|
||||
public boolean isBannedAddress(InetAddress address) throws UnknownHostException
|
||||
{
|
||||
String[] parts = address.getHostAddress().split("\\.");
|
||||
Long bi = _bannedIps.get(address);
|
||||
if (bi == null)
|
||||
{
|
||||
bi = _bannedIps.get(parts[0] + "." + parts[1] + "." + parts[2] + ".0");
|
||||
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + "." + parts[2] + ".0"));
|
||||
}
|
||||
if (bi == null)
|
||||
{
|
||||
bi = _bannedIps.get(parts[0] + "." + parts[1] + ".0.0");
|
||||
bi = _bannedIps.get(InetAddress.getByName(parts[0] + "." + parts[1] + ".0.0"));
|
||||
}
|
||||
if (bi == null)
|
||||
{
|
||||
bi = _bannedIps.get(parts[0] + ".0.0.0");
|
||||
bi = _bannedIps.get(InetAddress.getByName(parts[0] + ".0.0.0"));
|
||||
}
|
||||
if (bi != null)
|
||||
{
|
||||
@ -368,7 +368,7 @@ public class LoginController
|
||||
*/
|
||||
public boolean removeBanForAddress(InetAddress address)
|
||||
{
|
||||
return _bannedIps.remove(address.getHostAddress()) != null;
|
||||
return _bannedIps.remove(address) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,10 +18,12 @@
|
||||
*/
|
||||
package com.l2jserver.loginserver;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import commons.mmocore.IAcceptFilter;
|
||||
import commons.mmocore.IClientFactory;
|
||||
@ -38,6 +40,7 @@ import com.l2jserver.util.IPv4Filter;
|
||||
*/
|
||||
public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFactory<L2LoginClient>, IAcceptFilter
|
||||
{
|
||||
private static final Logger LOG = Logger.getLogger(LoginController.class.getName());
|
||||
private final ThreadPoolExecutor _generalPacketsThreadPool;
|
||||
private final IPv4Filter _ipv4filter;
|
||||
|
||||
@ -64,6 +67,14 @@ public class SelectorHelper implements IMMOExecutor<L2LoginClient>, IClientFacto
|
||||
@Override
|
||||
public boolean accept(SocketChannel sc)
|
||||
{
|
||||
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
|
||||
try
|
||||
{
|
||||
return _ipv4filter.accept(sc) && !LoginController.getInstance().isBannedAddress(sc.socket().getInetAddress());
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
LOG.severe(SelectorHelper.class.getSimpleName() + ": Invalid address: " + sc.socket().getInetAddress() + "; " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.ITelnetHandler;
|
||||
import com.l2jserver.gameserver.handler.TelnetHandler;
|
||||
|
||||
public class GameStatusThread extends Thread
|
||||
public final class GameStatusThread extends Thread
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(GameStatusThread.class.getName());
|
||||
|
||||
|
@ -37,7 +37,7 @@ import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jserver.loginserver.L2LoginServer;
|
||||
import com.l2jserver.loginserver.LoginController;
|
||||
|
||||
public class LoginStatusThread extends Thread
|
||||
public final class LoginStatusThread extends Thread
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(LoginStatusThread.class.getName());
|
||||
|
||||
|
@ -144,16 +144,19 @@ public interface IXmlReader
|
||||
return false;
|
||||
}
|
||||
|
||||
final File[] listOfFiles = dir.listFiles();
|
||||
for (File f : listOfFiles)
|
||||
final File[] files = dir.listFiles();
|
||||
if (files != null)
|
||||
{
|
||||
if (recursive && f.isDirectory())
|
||||
for (File f : files)
|
||||
{
|
||||
parseDirectory(f, recursive);
|
||||
}
|
||||
else if (getCurrentFileFilter().accept(f))
|
||||
{
|
||||
parseFile(f);
|
||||
if (recursive && f.isDirectory())
|
||||
{
|
||||
parseDirectory(f, recursive);
|
||||
}
|
||||
else if (getCurrentFileFilter().accept(f))
|
||||
{
|
||||
parseFile(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user