Sync with L2jServer HighFive Mar 25th 2015.
This commit is contained in:
@@ -23,9 +23,9 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -71,8 +71,8 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
|
||||
protected final Logger _log;
|
||||
|
||||
private final HashMap<Integer, L2SiegeClan> _attackers = new HashMap<>();
|
||||
private ArrayList<L2Spawn> _guards;
|
||||
private final Map<Integer, L2SiegeClan> _attackers = new ConcurrentHashMap<>();
|
||||
private List<L2Spawn> _guards;
|
||||
|
||||
public SiegableHall _hall;
|
||||
public ScheduledFuture<?> _siegeTask;
|
||||
@@ -91,8 +91,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
loadAttackers();
|
||||
}
|
||||
|
||||
// XXX Load methods -------------------------------
|
||||
|
||||
public void loadAttackers()
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
@@ -123,11 +121,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
delStatement.setInt(1, _hall.getId());
|
||||
delStatement.execute();
|
||||
|
||||
if (getAttackers().size() > 0)
|
||||
if (_attackers.size() > 0)
|
||||
{
|
||||
try (PreparedStatement insert = con.prepareStatement(SQL_SAVE_ATTACKERS))
|
||||
{
|
||||
for (L2SiegeClan clan : getAttackers().values())
|
||||
for (L2SiegeClan clan : _attackers.values())
|
||||
{
|
||||
insert.setInt(1, _hall.getId());
|
||||
insert.setInt(2, clan.getClanId());
|
||||
@@ -175,32 +173,24 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Npc Management methods ----------------------------
|
||||
|
||||
private final void spawnSiegeGuards()
|
||||
{
|
||||
for (L2Spawn guard : _guards)
|
||||
{
|
||||
if (guard != null)
|
||||
{
|
||||
guard.init();
|
||||
}
|
||||
guard.init();
|
||||
}
|
||||
}
|
||||
|
||||
private final void unSpawnSiegeGuards()
|
||||
{
|
||||
if ((_guards != null) && (_guards.size() > 0))
|
||||
if (_guards != null)
|
||||
{
|
||||
for (L2Spawn guard : _guards)
|
||||
{
|
||||
if (guard != null)
|
||||
guard.stopRespawn();
|
||||
if (guard.getLastSpawn() != null)
|
||||
{
|
||||
guard.stopRespawn();
|
||||
if (guard.getLastSpawn() != null)
|
||||
{
|
||||
guard.getLastSpawn().deleteMe();
|
||||
}
|
||||
guard.getLastSpawn().deleteMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,9 +208,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
return result;
|
||||
}
|
||||
|
||||
// XXX Attacker clans management -----------------------------
|
||||
|
||||
public final HashMap<Integer, L2SiegeClan> getAttackers()
|
||||
public final Map<Integer, L2SiegeClan> getAttackers()
|
||||
{
|
||||
return _attackers;
|
||||
}
|
||||
@@ -257,26 +245,21 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
@Override
|
||||
public List<L2SiegeClan> getAttackerClans()
|
||||
{
|
||||
ArrayList<L2SiegeClan> result = new ArrayList<>();
|
||||
result.addAll(_attackers.values());
|
||||
return result;
|
||||
return new ArrayList<>(_attackers.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<L2PcInstance> getAttackersInZone()
|
||||
{
|
||||
final Collection<L2PcInstance> list = _hall.getSiegeZone().getPlayersInside();
|
||||
List<L2PcInstance> attackers = new ArrayList<>();
|
||||
|
||||
for (L2PcInstance pc : list)
|
||||
final List<L2PcInstance> attackers = new ArrayList<>();
|
||||
for (L2PcInstance pc : _hall.getSiegeZone().getPlayersInside())
|
||||
{
|
||||
final L2Clan clan = pc.getClan();
|
||||
if ((clan != null) && getAttackers().containsKey(clan.getId()))
|
||||
if ((clan != null) && _attackers.containsKey(clan.getId()))
|
||||
{
|
||||
attackers.add(pc);
|
||||
}
|
||||
}
|
||||
|
||||
return attackers;
|
||||
}
|
||||
|
||||
@@ -298,14 +281,12 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
return null;
|
||||
}
|
||||
|
||||
// XXX Siege execution --------------------------
|
||||
|
||||
public void prepareOwner()
|
||||
{
|
||||
if (_hall.getOwnerId() > 0)
|
||||
{
|
||||
final L2SiegeClan clan = new L2SiegeClan(_hall.getOwnerId(), SiegeClanType.ATTACKER);
|
||||
getAttackers().put(clan.getClanId(), new L2SiegeClan(clan.getClanId(), SiegeClanType.ATTACKER));
|
||||
_attackers.put(clan.getClanId(), new L2SiegeClan(clan.getClanId(), SiegeClanType.ATTACKER));
|
||||
}
|
||||
|
||||
_hall.free();
|
||||
@@ -321,10 +302,10 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
@Override
|
||||
public void startSiege()
|
||||
{
|
||||
if ((getAttackers().size() < 1) && (_hall.getId() != 21)) // Fortress of resistance dont have attacker list
|
||||
if ((_attackers.size() < 1) && (_hall.getId() != 21)) // Fortress of resistance don't have attacker list
|
||||
{
|
||||
onSiegeEnds();
|
||||
getAttackers().clear();
|
||||
_attackers.clear();
|
||||
_hall.updateNextSiege();
|
||||
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new PrepareOwner(), _hall.getSiegeDate().getTimeInMillis());
|
||||
_hall.updateSiegeStatus(SiegeStatus.WAITING_BATTLE);
|
||||
@@ -340,7 +321,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
_hall.updateSiegeZone(true);
|
||||
|
||||
final byte state = 1;
|
||||
for (L2SiegeClan sClan : getAttackerClans())
|
||||
for (L2SiegeClan sClan : _attackers.values())
|
||||
{
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(sClan.getClanId());
|
||||
if (clan == null)
|
||||
@@ -350,12 +331,9 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
|
||||
for (L2PcInstance pc : clan.getOnlineMembers(0))
|
||||
{
|
||||
if (pc != null)
|
||||
{
|
||||
pc.setSiegeState(state);
|
||||
pc.broadcastUserInfo();
|
||||
pc.setIsInHideoutSiege(true);
|
||||
}
|
||||
pc.setSiegeState(state);
|
||||
pc.broadcastUserInfo();
|
||||
pc.setIsInHideoutSiege(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +374,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
_hall.banishForeigners();
|
||||
|
||||
final byte state = 0;
|
||||
for (L2SiegeClan sClan : getAttackerClans())
|
||||
for (L2SiegeClan sClan : _attackers.values())
|
||||
{
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(sClan.getClanId());
|
||||
if (clan == null)
|
||||
@@ -421,7 +399,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
}
|
||||
}
|
||||
|
||||
getAttackers().clear();
|
||||
_attackers.clear();
|
||||
|
||||
onSiegeEnds();
|
||||
|
||||
@@ -454,8 +432,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
return _hall.getSiegeDate();
|
||||
}
|
||||
|
||||
// XXX Fame settings ---------------------------
|
||||
|
||||
@Override
|
||||
public boolean giveFame()
|
||||
{
|
||||
@@ -468,8 +444,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
return Config.CHS_FAME_AMOUNT;
|
||||
}
|
||||
|
||||
// XXX Misc methods -----------------------------
|
||||
|
||||
@Override
|
||||
public int getFameFrequency()
|
||||
{
|
||||
@@ -489,7 +463,6 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Siege task and abstract methods -------------------
|
||||
public Location getInnerSpawnLoc(L2PcInstance player)
|
||||
{
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user