Project update.

This commit is contained in:
MobiusDev
2015-12-31 23:53:41 +00:00
parent e0d681a17e
commit ad2bcd79be
4084 changed files with 83696 additions and 86998 deletions

View File

@ -0,0 +1,232 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.entity.clanhall;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
import com.l2jmobius.gameserver.instancemanager.ClanHallManager;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.entity.ClanHall;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public final class AuctionableHall extends ClanHall
{
protected long _paidUntil;
private final int _grade;
protected boolean _paid;
private final int _lease;
private final int _chRate = 604800000;
public AuctionableHall(StatsSet set)
{
super(set);
_paidUntil = set.getLong("paidUntil");
_grade = set.getInt("grade");
_paid = set.getBoolean("paid");
_lease = set.getInt("lease");
if (getOwnerId() != 0)
{
_isFree = false;
initialyzeTask(false);
loadFunctions();
}
}
/**
* @return if clanHall is paid or not
*/
public final boolean getPaid()
{
return _paid;
}
/** Return lease */
@Override
public final int getLease()
{
return _lease;
}
/** Return PaidUntil */
@Override
public final long getPaidUntil()
{
return _paidUntil;
}
/** Return Grade */
@Override
public final int getGrade()
{
return _grade;
}
@Override
public final void free()
{
super.free();
_paidUntil = 0;
_paid = false;
}
@Override
public final void setOwner(L2Clan clan)
{
super.setOwner(clan);
_paidUntil = System.currentTimeMillis();
initialyzeTask(true);
}
/**
* Initialize Fee Task
* @param forced
*/
private final void initialyzeTask(boolean forced)
{
final long currentTime = System.currentTimeMillis();
if (_paidUntil > currentTime)
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), _paidUntil - currentTime);
}
else if (!_paid && !forced)
{
if ((System.currentTimeMillis() + (3600000 * 24)) <= (_paidUntil + _chRate))
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), System.currentTimeMillis() + (3600000 * 24));
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), (_paidUntil + _chRate) - System.currentTimeMillis());
}
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), 0);
}
}
/** Fee Task */
protected class FeeTask implements Runnable
{
private final Logger _log = Logger.getLogger(FeeTask.class.getName());
@Override
public void run()
{
try
{
final long _time = System.currentTimeMillis();
if (isFree())
{
return;
}
if (_paidUntil > _time)
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), _paidUntil - _time);
return;
}
final L2Clan Clan = ClanTable.getInstance().getClan(getOwnerId());
if (ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= getLease())
{
if (_paidUntil != 0)
{
while (_paidUntil <= _time)
{
_paidUntil += _chRate;
}
}
else
{
_paidUntil = _time + _chRate;
}
ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CH_rental_fee", Inventory.ADENA_ID, getLease(), null, null);
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), _paidUntil - _time);
_paid = true;
updateDb();
}
else
{
_paid = false;
if (_time > (_paidUntil + _chRate))
{
if (ClanHallManager.getInstance().loaded())
{
ClanHallAuctionManager.getInstance().initNPC(getId());
ClanHallManager.getInstance().setFree(getId());
Clan.broadcastToOnlineMembers(SystemMessage.getSystemMessage(SystemMessageId.THE_CLAN_HALL_FEE_IS_ONE_WEEK_OVERDUE));
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), 3000);
}
}
else
{
updateDb();
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_MAKE_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW);
sm.addInt(getLease());
Clan.broadcastToOnlineMembers(sm);
if ((_time + (3600000 * 24)) <= (_paidUntil + _chRate))
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), _time + (3600000 * 24));
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), (_paidUntil + _chRate) - _time);
}
}
}
}
catch (Exception e)
{
_log.log(Level.SEVERE, "", e);
}
}
}
@Override
public final void updateDb()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
{
ps.setInt(1, getOwnerId());
ps.setLong(2, getPaidUntil());
ps.setInt(3, (getPaid()) ? 1 : 0);
ps.setInt(4, getId());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: updateOwnerInDB(L2Clan clan): " + e.getMessage(), e);
}
}
}

View File

@ -0,0 +1,515 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.entity.clanhall;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.enums.SiegeClanType;
import com.l2jmobius.gameserver.instancemanager.CHSiegeManager;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2SiegeClan;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Siegable;
import com.l2jmobius.gameserver.model.quest.Quest;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.NpcSay;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* @author BiggBoss
*/
public abstract class ClanHallSiegeEngine extends Quest implements Siegable
{
private static final String SQL_LOAD_ATTACKERS = "SELECT attacker_id FROM clanhall_siege_attackers WHERE clanhall_id = ?";
private static final String SQL_SAVE_ATTACKERS = "INSERT INTO clanhall_siege_attackers VALUES (?,?)";
private static final String SQL_LOAD_GUARDS = "SELECT * FROM clanhall_siege_guards WHERE clanHallId = ?";
public static final int FORTRESS_RESSISTANCE = 21;
public static final int DEVASTATED_CASTLE = 34;
public static final int BANDIT_STRONGHOLD = 35;
public static final int RAINBOW_SPRINGS = 62;
public static final int BEAST_FARM = 63;
public static final int FORTRESS_OF_DEAD = 64;
protected final Logger _log;
private final Map<Integer, L2SiegeClan> _attackers = new ConcurrentHashMap<>();
private List<L2Spawn> _guards;
public SiegableHall _hall;
public ScheduledFuture<?> _siegeTask;
public boolean _missionAccomplished = false;
public ClanHallSiegeEngine(String name, String descr, final int hallId)
{
super(-1, name, descr);
_log = Logger.getLogger(getClass().getName());
_hall = CHSiegeManager.getInstance().getSiegableHall(hallId);
_hall.setSiege(this);
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new PrepareOwner(), _hall.getNextSiegeTime() - System.currentTimeMillis() - 3600000);
_log.config(_hall.getName() + " siege scheduled for " + getSiegeDate().getTime() + ".");
loadAttackers();
}
public void loadAttackers()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{
ps.setInt(1, _hall.getId());
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{
final int id = rset.getInt("attacker_id");
final L2SiegeClan clan = new L2SiegeClan(id, SiegeClanType.ATTACKER);
_attackers.put(id, clan);
}
}
}
catch (Exception e)
{
_log.warning(getName() + ": Could not load siege attackers!");
}
}
public final void saveAttackers()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
{
ps.setInt(1, _hall.getId());
ps.execute();
if (_attackers.size() > 0)
{
try (PreparedStatement insert = con.prepareStatement(SQL_SAVE_ATTACKERS))
{
for (L2SiegeClan clan : _attackers.values())
{
insert.setInt(1, _hall.getId());
insert.setInt(2, clan.getClanId());
insert.execute();
insert.clearParameters();
}
}
}
_log.config(getName() + ": Successfully saved attackers to database.");
}
catch (Exception e)
{
_log.warning(getName() + ": Couldn't save attacker list!");
}
}
public final void loadGuards()
{
if (_guards == null)
{
_guards = new ArrayList<>();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_GUARDS))
{
ps.setInt(1, _hall.getId());
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{
final L2Spawn spawn = new L2Spawn(rset.getInt("npcId"));
spawn.setX(rset.getInt("x"));
spawn.setY(rset.getInt("y"));
spawn.setZ(rset.getInt("z"));
spawn.setHeading(rset.getInt("heading"));
spawn.setRespawnDelay(rset.getInt("respawnDelay"));
spawn.setAmount(1);
_guards.add(spawn);
}
}
}
catch (Exception e)
{
_log.warning(getName() + ": Couldnt load siege guards!");
}
}
}
private final void spawnSiegeGuards()
{
for (L2Spawn guard : _guards)
{
guard.init();
}
}
private final void unSpawnSiegeGuards()
{
if (_guards != null)
{
for (L2Spawn guard : _guards)
{
guard.stopRespawn();
if (guard.getLastSpawn() != null)
{
guard.getLastSpawn().deleteMe();
}
}
}
}
@Override
public List<L2Npc> getFlag(L2Clan clan)
{
List<L2Npc> result = null;
final L2SiegeClan sClan = getAttackerClan(clan);
if (sClan != null)
{
result = sClan.getFlag();
}
return result;
}
public final Map<Integer, L2SiegeClan> getAttackers()
{
return _attackers;
}
@Override
public boolean checkIsAttacker(L2Clan clan)
{
if (clan == null)
{
return false;
}
return _attackers.containsKey(clan.getId());
}
@Override
public boolean checkIsDefender(L2Clan clan)
{
return false;
}
@Override
public L2SiegeClan getAttackerClan(int clanId)
{
return _attackers.get(clanId);
}
@Override
public L2SiegeClan getAttackerClan(L2Clan clan)
{
return getAttackerClan(clan.getId());
}
@Override
public List<L2SiegeClan> getAttackerClans()
{
return new ArrayList<>(_attackers.values());
}
@Override
public List<L2PcInstance> getAttackersInZone()
{
final List<L2PcInstance> attackers = new ArrayList<>();
for (L2PcInstance pc : _hall.getSiegeZone().getPlayersInside())
{
final L2Clan clan = pc.getClan();
if ((clan != null) && _attackers.containsKey(clan.getId()))
{
attackers.add(pc);
}
}
return attackers;
}
@Override
public L2SiegeClan getDefenderClan(int clanId)
{
return null;
}
@Override
public L2SiegeClan getDefenderClan(L2Clan clan)
{
return null;
}
@Override
public List<L2SiegeClan> getDefenderClans()
{
return null;
}
public void prepareOwner()
{
if (_hall.getOwnerId() > 0)
{
final L2SiegeClan clan = new L2SiegeClan(_hall.getOwnerId(), SiegeClanType.ATTACKER);
_attackers.put(clan.getClanId(), new L2SiegeClan(clan.getClanId(), SiegeClanType.ATTACKER));
}
_hall.free();
_hall.banishForeigners();
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.THE_REGISTRATION_TERM_FOR_S1_HAS_ENDED);
msg.addString(getName());
Broadcast.toAllOnlinePlayers(msg);
_hall.updateSiegeStatus(SiegeStatus.WAITING_BATTLE);
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new SiegeStarts(), 3600000);
}
@Override
public void startSiege()
{
if ((_attackers.size() < 1) && (_hall.getId() != 21)) // Fortress of resistance don't have attacker list
{
onSiegeEnds();
_attackers.clear();
_hall.updateNextSiege();
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new PrepareOwner(), _hall.getSiegeDate().getTimeInMillis());
_hall.updateSiegeStatus(SiegeStatus.WAITING_BATTLE);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_SIEGE_OF_S1_HAS_BEEN_CANCELED_DUE_TO_LACK_OF_INTEREST);
sm.addString(_hall.getName());
Broadcast.toAllOnlinePlayers(sm);
return;
}
_hall.spawnDoor();
loadGuards();
spawnSiegeGuards();
_hall.updateSiegeZone(true);
final byte state = 1;
for (L2SiegeClan sClan : _attackers.values())
{
final L2Clan clan = ClanTable.getInstance().getClan(sClan.getClanId());
if (clan == null)
{
continue;
}
for (L2PcInstance pc : clan.getOnlineMembers(0))
{
pc.setSiegeState(state);
pc.broadcastUserInfo();
pc.setIsInHideoutSiege(true);
}
}
_hall.updateSiegeStatus(SiegeStatus.RUNNING);
onSiegeStarts();
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new SiegeEnds(), _hall.getSiegeLenght());
}
@Override
public void endSiege()
{
final SystemMessage end = SystemMessage.getSystemMessage(SystemMessageId.THE_S1_SIEGE_HAS_FINISHED);
end.addString(_hall.getName());
Broadcast.toAllOnlinePlayers(end);
final L2Clan winner = getWinner();
SystemMessage finalMsg = null;
if (_missionAccomplished && (winner != null))
{
_hall.setOwner(winner);
winner.setHideoutId(_hall.getId());
finalMsg = SystemMessage.getSystemMessage(SystemMessageId.CLAN_S1_IS_VICTORIOUS_OVER_S2_S_CASTLE_SIEGE);
finalMsg.addString(winner.getName());
finalMsg.addString(_hall.getName());
Broadcast.toAllOnlinePlayers(finalMsg);
}
else
{
finalMsg = SystemMessage.getSystemMessage(SystemMessageId.THE_SIEGE_OF_S1_HAS_ENDED_IN_A_DRAW);
finalMsg.addString(_hall.getName());
Broadcast.toAllOnlinePlayers(finalMsg);
}
_missionAccomplished = false;
_hall.updateSiegeZone(false);
_hall.updateNextSiege();
_hall.spawnDoor(false);
_hall.banishForeigners();
final byte state = 0;
for (L2SiegeClan sClan : _attackers.values())
{
final L2Clan clan = ClanTable.getInstance().getClan(sClan.getClanId());
if (clan == null)
{
continue;
}
for (L2PcInstance player : clan.getOnlineMembers(0))
{
player.setSiegeState(state);
player.broadcastUserInfo();
player.setIsInHideoutSiege(false);
}
}
// Update pvp flag for winners when siege zone becomes inactive
for (L2Character chr : _hall.getSiegeZone().getCharactersInside())
{
if ((chr != null) && chr.isPlayer())
{
chr.getActingPlayer().startPvPFlag();
}
}
_attackers.clear();
onSiegeEnds();
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new PrepareOwner(), _hall.getNextSiegeTime() - System.currentTimeMillis() - 3600000);
_log.config("Siege of " + _hall.getName() + " scheduled for " + _hall.getSiegeDate().getTime() + ".");
_hall.updateSiegeStatus(SiegeStatus.REGISTERING);
unSpawnSiegeGuards();
}
@Override
public void updateSiege()
{
cancelSiegeTask();
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new PrepareOwner(), _hall.getNextSiegeTime() - 3600000);
_log.config(_hall.getName() + " siege scheduled for " + _hall.getSiegeDate().getTime().toString() + ".");
}
public void cancelSiegeTask()
{
if (_siegeTask != null)
{
_siegeTask.cancel(false);
}
}
@Override
public Calendar getSiegeDate()
{
return _hall.getSiegeDate();
}
@Override
public boolean giveFame()
{
return Config.CHS_ENABLE_FAME;
}
@Override
public int getFameAmount()
{
return Config.CHS_FAME_AMOUNT;
}
@Override
public int getFameFrequency()
{
return Config.CHS_FAME_FREQUENCY;
}
public final void broadcastNpcSay(final L2Npc npc, final ChatType type, final NpcStringId messageId)
{
final NpcSay npcSay = new NpcSay(npc.getObjectId(), type, npc.getId(), messageId);
final int sourceRegion = MapRegionManager.getInstance().getMapRegionLocId(npc);
for (L2PcInstance pc : L2World.getInstance().getPlayers())
{
if ((pc != null) && (MapRegionManager.getInstance().getMapRegionLocId(pc) == sourceRegion))
{
pc.sendPacket(npcSay);
}
}
}
public Location getInnerSpawnLoc(L2PcInstance player)
{
return null;
}
public boolean canPlantFlag()
{
return true;
}
public boolean doorIsAutoAttackable()
{
return true;
}
public void onSiegeStarts()
{
}
public void onSiegeEnds()
{
}
public abstract L2Clan getWinner();
public class PrepareOwner implements Runnable
{
@Override
public void run()
{
prepareOwner();
}
}
public class SiegeStarts implements Runnable
{
@Override
public void run()
{
startSiege();
}
}
public class SiegeEnds implements Runnable
{
@Override
public void run()
{
endSiege();
}
}
}

View File

@ -0,0 +1,278 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.entity.clanhall;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Calendar;
import java.util.logging.Level;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.gameserver.enums.SiegeClanType;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2SiegeClan;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.ClanHall;
import com.l2jmobius.gameserver.model.zone.type.L2SiegableHallZone;
import com.l2jmobius.gameserver.model.zone.type.L2SiegeZone;
import com.l2jmobius.gameserver.network.serverpackets.SiegeInfo;
/**
* @author BiggBoss
*/
public final class SiegableHall extends ClanHall
{
private static final String SQL_SAVE = "UPDATE siegable_clanhall SET ownerId=?, nextSiege=? WHERE clanHallId=?";
private Calendar _nextSiege;
private final long _siegeLength;
private final int[] _scheduleConfig =
{
7,
0,
0,
12,
0
};
private SiegeStatus _status = SiegeStatus.REGISTERING;
private L2SiegeZone _siegeZone;
private ClanHallSiegeEngine _siege;
public SiegableHall(StatsSet set)
{
super(set);
_siegeLength = set.getLong("siegeLenght");
final String[] rawSchConfig = set.getString("scheduleConfig").split(";");
if (rawSchConfig.length == 5)
{
for (int i = 0; i < 5; i++)
{
try
{
_scheduleConfig[i] = Integer.parseInt(rawSchConfig[i]);
}
catch (Exception e)
{
_log.warning("SiegableHall - " + getName() + ": Wrong schedule_config parameters!");
}
}
}
else
{
_log.warning(getName() + ": Wrong schedule_config value in siegable_halls table, using default (7 days)");
}
_nextSiege = Calendar.getInstance();
final long nextSiege = set.getLong("nextSiege");
if ((nextSiege - System.currentTimeMillis()) < 0)
{
updateNextSiege();
}
else
{
_nextSiege.setTimeInMillis(nextSiege);
}
if (getOwnerId() != 0)
{
_isFree = false;
loadFunctions();
}
}
public void spawnDoor()
{
spawnDoor(false);
}
public void spawnDoor(boolean isDoorWeak)
{
for (L2DoorInstance door : getDoors())
{
if (door.isDead())
{
door.doRevive();
if (isDoorWeak)
{
door.setCurrentHp(door.getMaxHp() / 2);
}
else
{
door.setCurrentHp(door.getMaxHp());
}
}
if (door.getOpen())
{
door.closeMe();
}
}
}
@Override
public final void updateDb()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE))
{
ps.setInt(1, getOwnerId());
ps.setLong(2, getNextSiegeTime());
ps.setInt(3, getId());
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception: SiegableHall.updateDb(): " + e.getMessage(), e);
}
}
public final void setSiege(final ClanHallSiegeEngine siegable)
{
_siege = siegable;
_siegeZone.setSiegeInstance(siegable);
}
public final ClanHallSiegeEngine getSiege()
{
return _siege;
}
public final Calendar getSiegeDate()
{
return _nextSiege;
}
public final long getNextSiegeTime()
{
return _nextSiege.getTimeInMillis();
}
public long getSiegeLenght()
{
return _siegeLength;
}
public final void setNextSiegeDate(long date)
{
_nextSiege.setTimeInMillis(date);
}
public final void setNextSiegeDate(final Calendar c)
{
_nextSiege = c;
}
public final void updateNextSiege()
{
final Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, _scheduleConfig[0]);
c.add(Calendar.MONTH, _scheduleConfig[1]);
c.add(Calendar.YEAR, _scheduleConfig[2]);
c.set(Calendar.HOUR_OF_DAY, _scheduleConfig[3]);
c.set(Calendar.MINUTE, _scheduleConfig[4]);
c.set(Calendar.SECOND, 0);
setNextSiegeDate(c);
updateDb();
}
public final void addAttacker(final L2Clan clan)
{
if (getSiege() != null)
{
getSiege().getAttackers().put(clan.getId(), new L2SiegeClan(clan.getId(), SiegeClanType.ATTACKER));
}
}
public final void removeAttacker(final L2Clan clan)
{
if (getSiege() != null)
{
getSiege().getAttackers().remove(clan.getId());
}
}
public final boolean isRegistered(L2Clan clan)
{
if (getSiege() == null)
{
return false;
}
return getSiege().checkIsAttacker(clan);
}
public SiegeStatus getSiegeStatus()
{
return _status;
}
public final boolean isRegistering()
{
return _status == SiegeStatus.REGISTERING;
}
public final boolean isInSiege()
{
return _status == SiegeStatus.RUNNING;
}
public final boolean isWaitingBattle()
{
return _status == SiegeStatus.WAITING_BATTLE;
}
public final void updateSiegeStatus(SiegeStatus status)
{
_status = status;
}
public final L2SiegeZone getSiegeZone()
{
return _siegeZone;
}
public final void setSiegeZone(L2SiegeZone zone)
{
_siegeZone = zone;
}
public final void updateSiegeZone(boolean active)
{
_siegeZone.setIsActive(active);
}
public final void showSiegeInfo(L2PcInstance player)
{
player.sendPacket(new SiegeInfo(this));
}
@Override
public final boolean isSiegableHall()
{
return true;
}
@Override
public L2SiegableHallZone getZone()
{
return (L2SiegableHallZone) super.getZone();
}
}

View File

@ -0,0 +1,27 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.entity.clanhall;
/**
* @author BiggBoss
*/
public enum SiegeStatus
{
REGISTERING,
WAITING_BATTLE,
RUNNING
}