Moved FortUpdater class in siege package.
This commit is contained in:
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -22,7 +22,6 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class managing periodical events with castle
|
* Class managing periodical events with castle
|
||||||
@@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort;
|
|||||||
public class FortUpdater implements Runnable
|
public class FortUpdater implements Runnable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
private final Clan _clan;
|
private final Clan _clan;
|
||||||
private final Fort _fort;
|
private final Fort _fort;
|
||||||
private int _runCount;
|
private int _runCount;
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -22,7 +22,6 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class managing periodical events with castle
|
* Class managing periodical events with castle
|
||||||
@@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort;
|
|||||||
public class FortUpdater implements Runnable
|
public class FortUpdater implements Runnable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
private final Clan _clan;
|
private final Clan _clan;
|
||||||
private final Fort _fort;
|
private final Fort _fort;
|
||||||
private int _runCount;
|
private int _runCount;
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -22,7 +22,6 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class managing periodical events with castle
|
* Class managing periodical events with castle
|
||||||
@@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort;
|
|||||||
public class FortUpdater implements Runnable
|
public class FortUpdater implements Runnable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
private final Clan _clan;
|
private final Clan _clan;
|
||||||
private final Fort _fort;
|
private final Fort _fort;
|
||||||
private int _runCount;
|
private int _runCount;
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver;
|
package org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -22,7 +22,6 @@ import java.util.logging.Logger;
|
|||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class managing periodical events with castle
|
* Class managing periodical events with castle
|
||||||
@@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort;
|
|||||||
public class FortUpdater implements Runnable
|
public class FortUpdater implements Runnable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
private final Clan _clan;
|
private final Clan _clan;
|
||||||
private final Fort _fort;
|
private final Fort _fort;
|
||||||
private int _runCount;
|
private int _runCount;
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,8 +37,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -56,6 +54,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -79,7 +78,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function;
|
private final Map<Integer, FortFunction> _function;
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -590,15 +589,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -924,7 +923,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,8 +37,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -56,6 +54,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -79,7 +78,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function;
|
private final Map<Integer, FortFunction> _function;
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -590,15 +589,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -924,7 +923,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
|
||||||
import org.l2jmobius.gameserver.model.siege.Fort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class managing periodical events with castle
|
|
||||||
* @author Vice - 2008
|
|
||||||
*/
|
|
||||||
public class FortUpdater implements Runnable
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
|
||||||
private final Clan _clan;
|
|
||||||
private final Fort _fort;
|
|
||||||
private int _runCount;
|
|
||||||
private final UpdaterType _updaterType;
|
|
||||||
|
|
||||||
public enum UpdaterType
|
|
||||||
{
|
|
||||||
MAX_OWN_TIME, // gives fort back to NPC clan
|
|
||||||
PERIODIC_UPDATE // raise blood oath/supply level
|
|
||||||
}
|
|
||||||
|
|
||||||
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
|
||||||
{
|
|
||||||
_fort = fort;
|
|
||||||
_clan = clan;
|
|
||||||
_runCount = runCount;
|
|
||||||
_updaterType = ut;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (_updaterType)
|
|
||||||
{
|
|
||||||
case PERIODIC_UPDATE:
|
|
||||||
{
|
|
||||||
_runCount++;
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fort.getOwnerClan().increaseBloodOathCount();
|
|
||||||
|
|
||||||
if (_fort.getFortState() == 2)
|
|
||||||
{
|
|
||||||
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
|
||||||
{
|
|
||||||
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
|
||||||
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
|
||||||
_fort.raiseSupplyLvL();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fort.setFortState(1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_fort.saveFortVariables();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MAX_OWN_TIME:
|
|
||||||
{
|
|
||||||
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
|
||||||
{
|
|
||||||
_fort.removeOwner(true);
|
|
||||||
_fort.setFortState(0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, "", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRunCount()
|
|
||||||
{
|
|
||||||
return _runCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
import org.l2jmobius.commons.util.Chronos;
|
import org.l2jmobius.commons.util.Chronos;
|
||||||
import org.l2jmobius.gameserver.FortUpdater;
|
|
||||||
import org.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
|
||||||
import org.l2jmobius.gameserver.data.SpawnTable;
|
import org.l2jmobius.gameserver.data.SpawnTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||||
@@ -55,6 +53,7 @@ import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
import org.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||||
|
import org.l2jmobius.gameserver.model.siege.FortUpdater.UpdaterType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
import org.l2jmobius.gameserver.model.zone.type.FortZone;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
import org.l2jmobius.gameserver.model.zone.type.SiegeZone;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
@@ -78,7 +77,7 @@ public class Fort extends AbstractResidence
|
|||||||
private int _castleId = 0;
|
private int _castleId = 0;
|
||||||
private int _supplyLvL = 0;
|
private int _supplyLvL = 0;
|
||||||
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
private final Map<Integer, FortFunction> _function = new ConcurrentHashMap<>();
|
||||||
private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
|
private final ScheduledFuture<?>[] _fortUpdater = new ScheduledFuture<?>[2];
|
||||||
|
|
||||||
// Spawn Data
|
// Spawn Data
|
||||||
private boolean _isSuspiciousMerchantSpawned = false;
|
private boolean _isSuspiciousMerchantSpawned = false;
|
||||||
@@ -589,15 +588,15 @@ public class Fort extends AbstractResidence
|
|||||||
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
initial = (Config.FS_UPDATE_FRQ * 60000) - initial;
|
||||||
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
|
||||||
{
|
{
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.schedule(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -815,32 +814,32 @@ public class Fort extends AbstractResidence
|
|||||||
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm));
|
||||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
_fortUpdater[0] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000, Config.FS_UPDATE_FRQ * 60000); // Schedule owner tasks to start running
|
||||||
if (Config.FS_MAX_OWN_TIME > 0)
|
if (Config.FS_MAX_OWN_TIME > 0)
|
||||||
{
|
{
|
||||||
_FortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
_fortUpdater[1] = ThreadPool.scheduleAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_FortUpdater[0] != null)
|
if (_fortUpdater[0] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[0].cancel(false);
|
_fortUpdater[0].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[0] = null;
|
_fortUpdater[0] = null;
|
||||||
if (_FortUpdater[1] != null)
|
if (_fortUpdater[1] != null)
|
||||||
{
|
{
|
||||||
_FortUpdater[1].cancel(false);
|
_fortUpdater[1].cancel(false);
|
||||||
}
|
}
|
||||||
_FortUpdater[1] = null;
|
_fortUpdater[1] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -931,7 +930,7 @@ public class Fort extends AbstractResidence
|
|||||||
|
|
||||||
public long getTimeTillNextFortUpdate()
|
public long getTimeTillNextFortUpdate()
|
||||||
{
|
{
|
||||||
return _FortUpdater[0] == null ? 0 : _FortUpdater[0].getDelay(TimeUnit.SECONDS);
|
return _fortUpdater[0] == null ? 0 : _fortUpdater[0].getDelay(TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClansReputation(Clan owner, boolean removePoints)
|
public void updateClansReputation(Clan owner, boolean removePoints)
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.l2jmobius.gameserver.model.siege;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class managing periodical events with castle
|
||||||
|
* @author Vice - 2008
|
||||||
|
*/
|
||||||
|
public class FortUpdater implements Runnable
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(FortUpdater.class.getName());
|
||||||
|
|
||||||
|
private final Clan _clan;
|
||||||
|
private final Fort _fort;
|
||||||
|
private int _runCount;
|
||||||
|
private final UpdaterType _updaterType;
|
||||||
|
|
||||||
|
public enum UpdaterType
|
||||||
|
{
|
||||||
|
MAX_OWN_TIME, // gives fort back to NPC clan
|
||||||
|
PERIODIC_UPDATE // raise blood oath/supply level
|
||||||
|
}
|
||||||
|
|
||||||
|
public FortUpdater(Fort fort, Clan clan, int runCount, UpdaterType ut)
|
||||||
|
{
|
||||||
|
_fort = fort;
|
||||||
|
_clan = clan;
|
||||||
|
_runCount = runCount;
|
||||||
|
_updaterType = ut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_updaterType)
|
||||||
|
{
|
||||||
|
case PERIODIC_UPDATE:
|
||||||
|
{
|
||||||
|
_runCount++;
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fort.getOwnerClan().increaseBloodOathCount();
|
||||||
|
|
||||||
|
if (_fort.getFortState() == 2)
|
||||||
|
{
|
||||||
|
if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
|
||||||
|
{
|
||||||
|
_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
|
||||||
|
_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
|
||||||
|
_fort.raiseSupplyLvL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fort.setFortState(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fort.saveFortVariables();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MAX_OWN_TIME:
|
||||||
|
{
|
||||||
|
if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
|
||||||
|
{
|
||||||
|
_fort.removeOwner(true);
|
||||||
|
_fort.setFortState(0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.WARNING, "", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunCount()
|
||||||
|
{
|
||||||
|
return _runCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user