diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java similarity index 93% rename from L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/FortUpdater.java rename to L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java index a502f222a1..8d7d54b0be 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/FortUpdater.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.model.siege; import java.util.logging.Level; import java.util.logging.Logger; @@ -22,7 +22,6 @@ 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 @@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort; 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; diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java similarity index 93% rename from L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/FortUpdater.java rename to L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java index a502f222a1..8d7d54b0be 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/FortUpdater.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.model.siege; import java.util.logging.Level; import java.util.logging.Logger; @@ -22,7 +22,6 @@ 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 @@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort; 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; diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java similarity index 93% rename from L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/FortUpdater.java rename to L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java index a502f222a1..8d7d54b0be 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/FortUpdater.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.model.siege; import java.util.logging.Level; import java.util.logging.Logger; @@ -22,7 +22,6 @@ 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 @@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort; 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; diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java similarity index 93% rename from L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/FortUpdater.java rename to L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java index a502f222a1..8d7d54b0be 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/FortUpdater.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver; +package org.l2jmobius.gameserver.model.siege; import java.util.logging.Level; import java.util.logging.Logger; @@ -22,7 +22,6 @@ 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 @@ -31,6 +30,7 @@ import org.l2jmobius.gameserver.model.siege.Fort; 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; diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Fort.java index 1331545059..d01c3dac3a 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -37,8 +37,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -79,7 +78,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function; - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -590,15 +589,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -924,7 +923,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Fort.java index 1331545059..d01c3dac3a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -37,8 +37,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -79,7 +78,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function; - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -590,15 +589,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -924,7 +923,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/FortUpdater.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/FortUpdater.java deleted file mode 100644 index a502f222a1..0000000000 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/FortUpdater.java +++ /dev/null @@ -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 . - */ -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; - } -} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Fort.java index de66de79ed..6ecb479a1e 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -36,8 +36,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.database.DatabaseFactory; 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.sql.ClanTable; 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.itemcontainer.Inventory; 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.SiegeZone; import org.l2jmobius.gameserver.network.SystemMessageId; @@ -78,7 +77,7 @@ public class Fort extends AbstractResidence private int _castleId = 0; private int _supplyLvL = 0; private final Map _function = new ConcurrentHashMap<>(); - private final ScheduledFuture[] _FortUpdater = new ScheduledFuture[2]; + private final ScheduledFuture[] _fortUpdater = new ScheduledFuture[2]; // Spawn Data private boolean _isSuspiciousMerchantSpawned = false; @@ -589,15 +588,15 @@ public class Fort extends AbstractResidence initial = (Config.FS_UPDATE_FRQ * 60000) - initial; 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) { - _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 { - _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 @@ -815,32 +814,32 @@ public class Fort extends AbstractResidence World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); 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) { - _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 { - if (_FortUpdater[0] != null) + if (_fortUpdater[0] != null) { - _FortUpdater[0].cancel(false); + _fortUpdater[0].cancel(false); } - _FortUpdater[0] = null; - if (_FortUpdater[1] != null) + _fortUpdater[0] = null; + if (_fortUpdater[1] != null) { - _FortUpdater[1].cancel(false); + _fortUpdater[1].cancel(false); } - _FortUpdater[1] = null; + _fortUpdater[1] = null; } } catch (Exception e) @@ -931,7 +930,7 @@ public class Fort extends AbstractResidence 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) diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java new file mode 100644 index 0000000000..8d7d54b0be --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/FortUpdater.java @@ -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 . + */ +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; + } +} \ No newline at end of file