diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index dda4fa4bdb..a6d1600cb8 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,7 @@ public class AddHuntingTime extends AbstractEffect } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); @@ -67,8 +67,7 @@ public class AddHuntingTime extends AbstractEffect if (player.isInTimedHuntingZone(_zoneId)) { - endTime = _time + player.getTimedHuntingZoneRemainingTime(); - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, _time + player.getTimedHuntingZoneRemainingTime(_zoneId)); player.startTimedHuntingZone(_zoneId, endTime); } else @@ -81,7 +80,7 @@ public class AddHuntingTime extends AbstractEffect { endTime = currentTime; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, (endTime - currentTime) + _time); } player.sendPacket(new TimedHuntingZoneList(player)); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 7ec596db09..ca74f89075 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -357,7 +357,6 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce; import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon; -import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; @@ -887,7 +886,7 @@ public class PlayerInstance extends Playable private final AutoPlaySettingsHolder _autoPlaySettings = new AutoPlaySettingsHolder(); private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder(); - private ScheduledFuture _timedHuntingZoneFinishTask = null; + private ScheduledFuture _timedHuntingZoneTask = null; private final List _questTimers = new ArrayList<>(); private final List> _timerHolders = new ArrayList<>(); @@ -13970,10 +13969,10 @@ public class PlayerInstance extends Playable _fallingDamageTask.cancel(false); _fallingDamageTask = null; } - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isDone() && !_timedHuntingZoneTask.isCancelled()) { - _timedHuntingZoneFinishTask.cancel(false); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; } if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled()) { @@ -14315,33 +14314,38 @@ public class PlayerInstance extends Playable // TODO: Delay window. // sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000))); sendMessage("You have " + (delay / 60 / 1000) + " minutes left for this timed zone."); - _timedHuntingZoneFinishTask = ThreadPool.schedule(() -> + _timedHuntingZoneTask = ThreadPool.scheduleAtFixedRate(() -> { - if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId)) + if (isInTimedHuntingZone(zoneId)) { - sendPacket(TimedHuntingZoneExit.STATIC_PACKET); - abortCast(); - stopMove(null); - teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + final long time = getTimedHuntingZoneRemainingTime(zoneId); + if (time > 0) + { + getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + zoneId, time - 60000); + } + else + { + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; + abortCast(); + stopMove(null); + teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + } } - }, delay); + }, 60000, 60000); } public void stopTimedHuntingZoneTask() { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isCancelled() && !_timedHuntingZoneTask.isDone()) { - _timedHuntingZoneFinishTask.cancel(true); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(true); + _timedHuntingZoneTask = null; } } - public long getTimedHuntingZoneRemainingTime() + public long getTimedHuntingZoneRemainingTime(int zoneId) { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) - { - return _timedHuntingZoneFinishTask.getDelay(TimeUnit.MILLISECONDS); - } - return 0; + return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0); } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java index 59df82911b..21114b528e 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java @@ -62,7 +62,8 @@ public class PlayerVariables extends AbstractVariables public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling"; public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat"; public static final String DELUSION_RETURN = "DELUSION_RETURN"; - public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_"; + public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_"; + public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_"; private final int _objectId; diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java index 0d94946342..d9345545a5 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java @@ -16,12 +16,10 @@ */ package org.l2jmobius.gameserver.model.zone.type; -import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; @@ -44,16 +42,15 @@ public class TimedHuntingZone extends ZoneType { player.setInsideZone(ZoneId.TIMED_HUNTING, true); - final long currentTime = Chronos.currentTimeMillis(); - final long stormIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); - final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); - if ((stormIsleExitTime > currentTime) && player.isInTimedHuntingZone(1)) + final long stormIsleExitTime = player.getTimedHuntingZoneRemainingTime(1); + final long primevalIsleExitTime = player.getTimedHuntingZoneRemainingTime(6); + if ((stormIsleExitTime > 0) && player.isInTimedHuntingZone(1)) { - player.startTimedHuntingZone(1, stormIsleExitTime - currentTime); + player.startTimedHuntingZone(1, stormIsleExitTime); } - else if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(6)) + else if ((primevalIsleExitTime > 0) && player.isInTimedHuntingZone(6)) { - player.startTimedHuntingZone(6, primevalIsleExitTime - currentTime); + player.startTimedHuntingZone(6, primevalIsleExitTime); } else if (!player.isGM()) { diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index f7716bdd1f..ad27af06cd 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -79,7 +79,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket player.sendMessage("Cannot use time-limited hunting zones while registered on an event."); return; } - if (player.isInInstance()) + if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY())) { player.sendMessage("Cannot use time-limited hunting zones while in an instance."); return; @@ -93,10 +93,15 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); + final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0); + if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } if (endTime > currentTime) @@ -111,7 +116,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket return; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime); switch (_zoneId) { diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index 9e3aded1c6..2c022a0a2e 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -20,7 +20,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -56,8 +55,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(1); // zone id packet.writeD(100); // min level packet.writeD(120); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(1); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -76,8 +79,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(6); // zone id packet.writeD(105); // min level packet.writeD(120); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(6); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index 5168629d5f..07f519c382 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,7 @@ public class AddHuntingTime extends AbstractEffect } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); if ((_zoneId == 8) && (endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME_WEEKLY)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); @@ -73,8 +73,7 @@ public class AddHuntingTime extends AbstractEffect if (player.isInTimedHuntingZone(_zoneId)) { - endTime = _time + player.getTimedHuntingZoneRemainingTime(); - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, _time + player.getTimedHuntingZoneRemainingTime(_zoneId)); player.startTimedHuntingZone(_zoneId, endTime); } else @@ -91,7 +90,7 @@ public class AddHuntingTime extends AbstractEffect { endTime = currentTime; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, (endTime - currentTime) + _time); } player.sendPacket(new TimedHuntingZoneList(player)); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 3ce80d8f4a..1ebb219829 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -353,7 +353,6 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlaySettingSend; import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; -import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; @@ -881,7 +880,7 @@ public class PlayerInstance extends Playable private final AutoPlaySettingsHolder _autoPlaySettings = new AutoPlaySettingsHolder(); private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder(); - private ScheduledFuture _timedHuntingZoneFinishTask = null; + private ScheduledFuture _timedHuntingZoneTask = null; private int _homunculusHpBonus; private int _homunculusAtkBonus; @@ -14053,10 +14052,10 @@ public class PlayerInstance extends Playable _fallingDamageTask.cancel(false); _fallingDamageTask = null; } - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isDone() && !_timedHuntingZoneTask.isCancelled()) { - _timedHuntingZoneFinishTask.cancel(false); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; } if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled()) { @@ -14334,7 +14333,6 @@ public class PlayerInstance extends Playable { final int x = ((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN; final int y = ((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN; - switch (zoneId) { case 1: // Storm Isle @@ -14373,34 +14371,39 @@ public class PlayerInstance extends Playable // TODO: Delay window. // sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000))); sendMessage("You have " + (delay / 60 / 1000) + " minutes left for this timed zone."); - _timedHuntingZoneFinishTask = ThreadPool.schedule(() -> + _timedHuntingZoneTask = ThreadPool.scheduleAtFixedRate(() -> { - if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId)) + if (isInTimedHuntingZone(zoneId)) { - sendPacket(TimedHuntingZoneExit.STATIC_PACKET); - abortCast(); - stopMove(null); - teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + final long time = getTimedHuntingZoneRemainingTime(zoneId); + if (time > 0) + { + getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + zoneId, time - 60000); + } + else + { + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; + abortCast(); + stopMove(null); + teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + } } - }, delay); + }, 60000, 60000); } public void stopTimedHuntingZoneTask() { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isCancelled() && !_timedHuntingZoneTask.isDone()) { - _timedHuntingZoneFinishTask.cancel(true); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(true); + _timedHuntingZoneTask = null; } } - public long getTimedHuntingZoneRemainingTime() + public long getTimedHuntingZoneRemainingTime(int zoneId) { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) - { - return _timedHuntingZoneFinishTask.getDelay(TimeUnit.MILLISECONDS); - } - return 0; + return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0); } public int getHomunculusHpBonus() diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java index 61145c4789..0764d91e54 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java @@ -62,7 +62,8 @@ public class PlayerVariables extends AbstractVariables public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling"; public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat"; public static final String DELUSION_RETURN = "DELUSION_RETURN"; - public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_"; + public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_"; + public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_"; public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS"; public static final String HOMUNCULUS_STATUS = "HOMUNCULUS_STATUS"; public static final String HOMUNCULUS_TIME = "HOMUNCULUS_TIME"; diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java index 35023d8925..9a6cb3747a 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java @@ -16,12 +16,10 @@ */ package org.l2jmobius.gameserver.model.zone.type; -import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; @@ -44,36 +42,35 @@ public class TimedHuntingZone extends ZoneType { player.setInsideZone(ZoneId.TIMED_HUNTING, true); - final long currentTime = Chronos.currentTimeMillis(); - final long stormIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); - final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); - final long goldenAltarExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0); - final long coalMinesExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); - final long toiExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0); - final long imperialTombExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); - if ((stormIsleExitTime > currentTime) && player.isInTimedHuntingZone(1)) + final long stormIsleExitTime = player.getTimedHuntingZoneRemainingTime(1); + final long primevalIsleExitTime = player.getTimedHuntingZoneRemainingTime(6); + final long goldenAltarExitTime = player.getTimedHuntingZoneRemainingTime(7); + final long coalMinesExitTime = player.getTimedHuntingZoneRemainingTime(11); + final long toiExitTime = player.getTimedHuntingZoneRemainingTime(8); + final long imperialTombExitTime = player.getTimedHuntingZoneRemainingTime(12); + if ((stormIsleExitTime > 0) && player.isInTimedHuntingZone(1)) { - player.startTimedHuntingZone(1, stormIsleExitTime - currentTime); + player.startTimedHuntingZone(1, stormIsleExitTime); } - else if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(6)) + else if ((primevalIsleExitTime > 0) && player.isInTimedHuntingZone(6)) { - player.startTimedHuntingZone(6, primevalIsleExitTime - currentTime); + player.startTimedHuntingZone(6, primevalIsleExitTime); } - else if ((goldenAltarExitTime > currentTime) && player.isInTimedHuntingZone(7)) + else if ((goldenAltarExitTime > 0) && player.isInTimedHuntingZone(7)) { - player.startTimedHuntingZone(7, goldenAltarExitTime - currentTime); + player.startTimedHuntingZone(7, goldenAltarExitTime); } - else if ((coalMinesExitTime > currentTime) && player.isInTimedHuntingZone(11)) + else if ((coalMinesExitTime > 0) && player.isInTimedHuntingZone(11)) { - player.startTimedHuntingZone(11, coalMinesExitTime - currentTime); + player.startTimedHuntingZone(11, coalMinesExitTime); } - else if ((toiExitTime > currentTime) && player.isInTimedHuntingZone(8)) + else if ((toiExitTime > 0) && player.isInTimedHuntingZone(8)) { - player.startTimedHuntingZone(8, toiExitTime - currentTime); + player.startTimedHuntingZone(8, toiExitTime); } - else if ((imperialTombExitTime > currentTime) && player.isInTimedHuntingZone(12)) + else if ((imperialTombExitTime > 0) && player.isInTimedHuntingZone(12)) { - player.startTimedHuntingZone(12, imperialTombExitTime - currentTime); + player.startTimedHuntingZone(12, imperialTombExitTime); } else if (!player.isGM()) { diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index 926c5622f3..f001b1d7e4 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -79,7 +79,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket player.sendMessage("Cannot use time-limited hunting zones while registered on an event."); return; } - if (player.isInInstance()) + if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY())) { player.sendMessage("Cannot use time-limited hunting zones while in an instance."); return; @@ -97,15 +97,23 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - - if ((_zoneId == 8) && ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime)) + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); + final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0); + if ((_zoneId == 8) && ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime)) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } - else if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + else if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } if (endTime > currentTime) @@ -120,7 +128,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket return; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime); switch (_zoneId) { diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index af05989355..5ad0d51367 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -20,7 +20,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -57,7 +56,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(100); // min level packet.writeD(120); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(1); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -78,7 +81,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(105); // min level packet.writeD(120); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(6); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -99,7 +106,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(107); // min level packet.writeD(120); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(7); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -120,7 +131,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(99); // min level packet.writeD(105); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(11); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -141,7 +156,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(110); // min level packet.writeD(130); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(8); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; @@ -162,7 +181,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(105); // min level packet.writeD(130); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(12); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index 5168629d5f..07f519c382 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,7 @@ public class AddHuntingTime extends AbstractEffect } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); if ((_zoneId == 8) && (endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME_WEEKLY)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); @@ -73,8 +73,7 @@ public class AddHuntingTime extends AbstractEffect if (player.isInTimedHuntingZone(_zoneId)) { - endTime = _time + player.getTimedHuntingZoneRemainingTime(); - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, _time + player.getTimedHuntingZoneRemainingTime(_zoneId)); player.startTimedHuntingZone(_zoneId, endTime); } else @@ -91,7 +90,7 @@ public class AddHuntingTime extends AbstractEffect { endTime = currentTime; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, (endTime - currentTime) + _time); } player.sendPacket(new TimedHuntingZoneList(player)); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 9086a23196..fc0a9d0325 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -353,7 +353,6 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlaySettingSend; import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; -import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; @@ -881,7 +880,7 @@ public class PlayerInstance extends Playable private final AutoPlaySettingsHolder _autoPlaySettings = new AutoPlaySettingsHolder(); private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder(); - private ScheduledFuture _timedHuntingZoneFinishTask = null; + private ScheduledFuture _timedHuntingZoneTask = null; private int _homunculusHpBonus; private int _homunculusAtkBonus; @@ -14063,10 +14062,10 @@ public class PlayerInstance extends Playable _fallingDamageTask.cancel(false); _fallingDamageTask = null; } - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isDone() && !_timedHuntingZoneTask.isCancelled()) { - _timedHuntingZoneFinishTask.cancel(false); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; } if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled()) { @@ -14344,7 +14343,6 @@ public class PlayerInstance extends Playable { final int x = ((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN; final int y = ((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN; - switch (zoneId) { case 1: // Storm Isle @@ -14383,34 +14381,39 @@ public class PlayerInstance extends Playable // TODO: Delay window. // sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000))); sendMessage("You have " + (delay / 60 / 1000) + " minutes left for this timed zone."); - _timedHuntingZoneFinishTask = ThreadPool.schedule(() -> + _timedHuntingZoneTask = ThreadPool.scheduleAtFixedRate(() -> { - if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId)) + if (isInTimedHuntingZone(zoneId)) { - sendPacket(TimedHuntingZoneExit.STATIC_PACKET); - abortCast(); - stopMove(null); - teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + final long time = getTimedHuntingZoneRemainingTime(zoneId); + if (time > 0) + { + getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + zoneId, time - 60000); + } + else + { + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; + abortCast(); + stopMove(null); + teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + } } - }, delay); + }, 60000, 60000); } public void stopTimedHuntingZoneTask() { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isCancelled() && !_timedHuntingZoneTask.isDone()) { - _timedHuntingZoneFinishTask.cancel(true); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(true); + _timedHuntingZoneTask = null; } } - public long getTimedHuntingZoneRemainingTime() + public long getTimedHuntingZoneRemainingTime(int zoneId) { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) - { - return _timedHuntingZoneFinishTask.getDelay(TimeUnit.MILLISECONDS); - } - return 0; + return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0); } public int getHomunculusHpBonus() diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java index 61145c4789..0764d91e54 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java @@ -62,7 +62,8 @@ public class PlayerVariables extends AbstractVariables public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling"; public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat"; public static final String DELUSION_RETURN = "DELUSION_RETURN"; - public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_"; + public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_"; + public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_"; public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS"; public static final String HOMUNCULUS_STATUS = "HOMUNCULUS_STATUS"; public static final String HOMUNCULUS_TIME = "HOMUNCULUS_TIME"; diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java index 35023d8925..9a6cb3747a 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java @@ -16,12 +16,10 @@ */ package org.l2jmobius.gameserver.model.zone.type; -import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; @@ -44,36 +42,35 @@ public class TimedHuntingZone extends ZoneType { player.setInsideZone(ZoneId.TIMED_HUNTING, true); - final long currentTime = Chronos.currentTimeMillis(); - final long stormIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); - final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); - final long goldenAltarExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0); - final long coalMinesExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); - final long toiExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0); - final long imperialTombExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); - if ((stormIsleExitTime > currentTime) && player.isInTimedHuntingZone(1)) + final long stormIsleExitTime = player.getTimedHuntingZoneRemainingTime(1); + final long primevalIsleExitTime = player.getTimedHuntingZoneRemainingTime(6); + final long goldenAltarExitTime = player.getTimedHuntingZoneRemainingTime(7); + final long coalMinesExitTime = player.getTimedHuntingZoneRemainingTime(11); + final long toiExitTime = player.getTimedHuntingZoneRemainingTime(8); + final long imperialTombExitTime = player.getTimedHuntingZoneRemainingTime(12); + if ((stormIsleExitTime > 0) && player.isInTimedHuntingZone(1)) { - player.startTimedHuntingZone(1, stormIsleExitTime - currentTime); + player.startTimedHuntingZone(1, stormIsleExitTime); } - else if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(6)) + else if ((primevalIsleExitTime > 0) && player.isInTimedHuntingZone(6)) { - player.startTimedHuntingZone(6, primevalIsleExitTime - currentTime); + player.startTimedHuntingZone(6, primevalIsleExitTime); } - else if ((goldenAltarExitTime > currentTime) && player.isInTimedHuntingZone(7)) + else if ((goldenAltarExitTime > 0) && player.isInTimedHuntingZone(7)) { - player.startTimedHuntingZone(7, goldenAltarExitTime - currentTime); + player.startTimedHuntingZone(7, goldenAltarExitTime); } - else if ((coalMinesExitTime > currentTime) && player.isInTimedHuntingZone(11)) + else if ((coalMinesExitTime > 0) && player.isInTimedHuntingZone(11)) { - player.startTimedHuntingZone(11, coalMinesExitTime - currentTime); + player.startTimedHuntingZone(11, coalMinesExitTime); } - else if ((toiExitTime > currentTime) && player.isInTimedHuntingZone(8)) + else if ((toiExitTime > 0) && player.isInTimedHuntingZone(8)) { - player.startTimedHuntingZone(8, toiExitTime - currentTime); + player.startTimedHuntingZone(8, toiExitTime); } - else if ((imperialTombExitTime > currentTime) && player.isInTimedHuntingZone(12)) + else if ((imperialTombExitTime > 0) && player.isInTimedHuntingZone(12)) { - player.startTimedHuntingZone(12, imperialTombExitTime - currentTime); + player.startTimedHuntingZone(12, imperialTombExitTime); } else if (!player.isGM()) { diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index 926c5622f3..f001b1d7e4 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -79,7 +79,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket player.sendMessage("Cannot use time-limited hunting zones while registered on an event."); return; } - if (player.isInInstance()) + if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY())) { player.sendMessage("Cannot use time-limited hunting zones while in an instance."); return; @@ -97,15 +97,23 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - - if ((_zoneId == 8) && ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime)) + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); + final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0); + if ((_zoneId == 8) && ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime)) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } - else if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + else if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } if (endTime > currentTime) @@ -120,7 +128,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket return; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime); switch (_zoneId) { diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index af05989355..5ad0d51367 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -20,7 +20,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -57,7 +56,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(100); // min level packet.writeD(120); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(1); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -78,7 +81,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(105); // min level packet.writeD(120); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(6); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -99,7 +106,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(107); // min level packet.writeD(120); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(7); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -120,7 +131,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(99); // min level packet.writeD(105); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(11); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -141,7 +156,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(110); // min level packet.writeD(130); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(8); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; @@ -162,7 +181,11 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(105); // min level packet.writeD(130); // max level packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); + endTime = _player.getTimedHuntingZoneRemainingTime(12); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index dda4fa4bdb..a6d1600cb8 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,7 @@ public class AddHuntingTime extends AbstractEffect } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); @@ -67,8 +67,7 @@ public class AddHuntingTime extends AbstractEffect if (player.isInTimedHuntingZone(_zoneId)) { - endTime = _time + player.getTimedHuntingZoneRemainingTime(); - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, _time + player.getTimedHuntingZoneRemainingTime(_zoneId)); player.startTimedHuntingZone(_zoneId, endTime); } else @@ -81,7 +80,7 @@ public class AddHuntingTime extends AbstractEffect { endTime = currentTime; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, (endTime - currentTime) + _time); } player.sendPacket(new TimedHuntingZoneList(player)); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index b3dd89c36e..c6fa036982 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -354,7 +354,6 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation; import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlaySettingSend; import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; -import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; @@ -869,7 +868,7 @@ public class PlayerInstance extends Playable private final AutoPlaySettingsHolder _autoPlaySettings = new AutoPlaySettingsHolder(); private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder(); - private ScheduledFuture _timedHuntingZoneFinishTask = null; + private ScheduledFuture _timedHuntingZoneTask = null; private final List _questTimers = new ArrayList<>(); private final List> _timerHolders = new ArrayList<>(); @@ -13777,10 +13776,10 @@ public class PlayerInstance extends Playable _fallingDamageTask.cancel(false); _fallingDamageTask = null; } - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isDone() && !_timedHuntingZoneTask.isCancelled()) { - _timedHuntingZoneFinishTask.cancel(false); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; } if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled()) { @@ -14213,33 +14212,38 @@ public class PlayerInstance extends Playable // TODO: Delay window. // sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000))); sendMessage("You have " + (delay / 60 / 1000) + " minutes left for this timed zone."); - _timedHuntingZoneFinishTask = ThreadPool.schedule(() -> + _timedHuntingZoneTask = ThreadPool.scheduleAtFixedRate(() -> { - if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId)) + if (isInTimedHuntingZone(zoneId)) { - sendPacket(TimedHuntingZoneExit.STATIC_PACKET); - abortCast(); - stopMove(null); - teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + final long time = getTimedHuntingZoneRemainingTime(zoneId); + if (time > 0) + { + getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + zoneId, time - 60000); + } + else + { + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; + abortCast(); + stopMove(null); + teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + } } - }, delay); + }, 60000, 60000); } public void stopTimedHuntingZoneTask() { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isCancelled() && !_timedHuntingZoneTask.isDone()) { - _timedHuntingZoneFinishTask.cancel(true); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(true); + _timedHuntingZoneTask = null; } } - public long getTimedHuntingZoneRemainingTime() + public long getTimedHuntingZoneRemainingTime(int zoneId) { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) - { - return _timedHuntingZoneFinishTask.getDelay(TimeUnit.MILLISECONDS); - } - return 0; + return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java index 2d3f24387b..06dba0a244 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java @@ -63,7 +63,8 @@ public class PlayerVariables extends AbstractVariables public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling"; public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat"; public static final String DELUSION_RETURN = "DELUSION_RETURN"; - public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_"; + public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_"; + public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_"; private final int _objectId; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java index bf7b8e9e2f..ce5ef68b39 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java @@ -16,12 +16,10 @@ */ package org.l2jmobius.gameserver.model.zone.type; -import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; @@ -44,11 +42,10 @@ public class TimedHuntingZone extends ZoneType { player.setInsideZone(ZoneId.TIMED_HUNTING, true); - final long currentTime = Chronos.currentTimeMillis(); - final long pirateTombExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 2, 0); - if ((pirateTombExitTime > currentTime) && player.isInTimedHuntingZone(2)) + final long pirateTombExitTime = player.getTimedHuntingZoneRemainingTime(2); + if ((pirateTombExitTime > 0) && player.isInTimedHuntingZone(2)) { - player.startTimedHuntingZone(2, pirateTombExitTime - currentTime); + player.startTimedHuntingZone(2, pirateTombExitTime); } else if (!player.isGM()) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index 92514b42f2..76848670c9 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -78,7 +78,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket player.sendMessage("Cannot use time-limited hunting zones while registered on an event."); return; } - if (player.isInInstance()) + if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY())) { player.sendMessage("Cannot use time-limited hunting zones while in an instance."); return; @@ -90,10 +90,15 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); + final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0); + if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } if (endTime > currentTime) @@ -108,7 +113,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket return; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime); switch (_zoneId) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index 8024125f3b..0bf985eaed 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -20,7 +20,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -56,8 +55,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(2); // zone id packet.writeD(78); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 2, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(2); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index 41e0e929ec..7d376e0c47 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,7 @@ public class AddHuntingTime extends AbstractEffect } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); @@ -91,8 +91,7 @@ public class AddHuntingTime extends AbstractEffect if (player.isInTimedHuntingZone(_zoneId)) { - endTime = _time + player.getTimedHuntingZoneRemainingTime(); - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, _time + player.getTimedHuntingZoneRemainingTime(_zoneId)); player.startTimedHuntingZone(_zoneId, endTime); } else @@ -113,7 +112,7 @@ public class AddHuntingTime extends AbstractEffect { endTime = currentTime; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, (endTime - currentTime) + _time); } player.sendPacket(new TimedHuntingZoneList(player)); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 33ead799bf..dbccce4340 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -361,7 +361,6 @@ import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlaySetting import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; -import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; @@ -887,7 +886,7 @@ public class PlayerInstance extends Playable private final AutoPlaySettingsHolder _autoPlaySettings = new AutoPlaySettingsHolder(); private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder(); - private ScheduledFuture _timedHuntingZoneFinishTask = null; + private ScheduledFuture _timedHuntingZoneTask = null; private PlayerRandomCraft _randomCraft = null; @@ -14010,10 +14009,10 @@ public class PlayerInstance extends Playable _fallingDamageTask.cancel(false); _fallingDamageTask = null; } - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isDone() && !_timedHuntingZoneTask.isCancelled()) { - _timedHuntingZoneFinishTask.cancel(false); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; } if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled()) { @@ -14495,34 +14494,39 @@ public class PlayerInstance extends Playable // TODO: Delay window. // sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000))); sendMessage("You have " + (delay / 60 / 1000) + " minutes left for this timed zone."); - _timedHuntingZoneFinishTask = ThreadPool.schedule(() -> + _timedHuntingZoneTask = ThreadPool.scheduleAtFixedRate(() -> { - if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId)) + if (isInTimedHuntingZone(zoneId)) { - sendPacket(TimedHuntingZoneExit.STATIC_PACKET); - abortCast(); - stopMove(null); - teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + final long time = getTimedHuntingZoneRemainingTime(zoneId); + if (time > 0) + { + getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + zoneId, time - 60000); + } + else + { + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; + abortCast(); + stopMove(null); + teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + } } - }, delay); + }, 60000, 60000); } public void stopTimedHuntingZoneTask() { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isCancelled() && !_timedHuntingZoneTask.isDone()) { - _timedHuntingZoneFinishTask.cancel(true); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(true); + _timedHuntingZoneTask = null; } } - public long getTimedHuntingZoneRemainingTime() + public long getTimedHuntingZoneRemainingTime(int zoneId) { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) - { - return _timedHuntingZoneFinishTask.getDelay(TimeUnit.MILLISECONDS); - } - return 0; + return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0); } private void restoreRandomCraft() diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java index a384d2efb7..bb78ecf215 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java @@ -63,7 +63,8 @@ public class PlayerVariables extends AbstractVariables public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling"; public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat"; public static final String DELUSION_RETURN = "DELUSION_RETURN"; - public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_"; + public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_"; + public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_"; public static final String SAYHA_GRACE_SUPPORT_ENDTIME = "SAYHA_GRACE_SUPPORT_ENDTIME"; public static final String LIMITED_SAYHA_GRACE_ENDTIME = "LIMITED_SAYHA_GRACE_ENDTIME"; public static final String MAGIC_LAMP_EXP = "MAGIC_LAMP_EXP"; diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java index 190ab2ef14..52bb5bf73b 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java @@ -16,12 +16,10 @@ */ package org.l2jmobius.gameserver.model.zone.type; -import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; @@ -44,57 +42,56 @@ public class TimedHuntingZone extends ZoneType { player.setInsideZone(ZoneId.TIMED_HUNTING, true); - final long currentTime = Chronos.currentTimeMillis(); - final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); - final long PrimevalGardenExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 4, 0); - final long AlligatorIslandExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); - final long AntharasLairExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); - final long Transcendent1ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 101, 0); - final long Transcendent2ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 102, 0); - final long Transcendent3ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 103, 0); - final long Transcendent4ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 104, 0); - final long Transcendent6ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 106, 0); - final long Transcendent7ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 107, 0); + final long primevalIsleExitTime = player.getTimedHuntingZoneRemainingTime(1); + final long primevalGardenExitTime = player.getTimedHuntingZoneRemainingTime(4); + final long alligatorIslandExitTime = player.getTimedHuntingZoneRemainingTime(11); + final long antharasLairExitTime = player.getTimedHuntingZoneRemainingTime(12); + final long transcendent1ExitTime = player.getTimedHuntingZoneRemainingTime(101); + final long transcendent2ExitTime = player.getTimedHuntingZoneRemainingTime(102); + final long transcendent3ExitTime = player.getTimedHuntingZoneRemainingTime(103); + final long transcendent4ExitTime = player.getTimedHuntingZoneRemainingTime(104); + final long transcendent6ExitTime = player.getTimedHuntingZoneRemainingTime(106); + final long transcendent7ExitTime = player.getTimedHuntingZoneRemainingTime(107); - if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(1)) + if ((primevalIsleExitTime > 0) && player.isInTimedHuntingZone(1)) { - player.startTimedHuntingZone(1, primevalIsleExitTime - currentTime); + player.startTimedHuntingZone(1, primevalIsleExitTime); } - else if ((PrimevalGardenExitTime > currentTime) && player.isInTimedHuntingZone(4)) + else if ((primevalGardenExitTime > 0) && player.isInTimedHuntingZone(4)) { - player.startTimedHuntingZone(4, PrimevalGardenExitTime - currentTime); + player.startTimedHuntingZone(4, primevalGardenExitTime); } - else if ((AlligatorIslandExitTime > currentTime) && player.isInTimedHuntingZone(11)) + else if ((alligatorIslandExitTime > 0) && player.isInTimedHuntingZone(11)) { - player.startTimedHuntingZone(11, AlligatorIslandExitTime - currentTime); + player.startTimedHuntingZone(11, alligatorIslandExitTime); } - else if ((AntharasLairExitTime > currentTime) && player.isInTimedHuntingZone(12)) + else if ((antharasLairExitTime > 0) && player.isInTimedHuntingZone(12)) { - player.startTimedHuntingZone(12, AntharasLairExitTime - currentTime); + player.startTimedHuntingZone(12, antharasLairExitTime); } - else if ((Transcendent1ExitTime > currentTime) && player.isInTimedHuntingZone(101)) + else if ((transcendent1ExitTime > 0) && player.isInTimedHuntingZone(101)) { - player.startTimedHuntingZone(101, Transcendent1ExitTime - currentTime); + player.startTimedHuntingZone(101, transcendent1ExitTime); } - else if ((Transcendent2ExitTime > currentTime) && player.isInTimedHuntingZone(102)) + else if ((transcendent2ExitTime > 0) && player.isInTimedHuntingZone(102)) { - player.startTimedHuntingZone(102, Transcendent2ExitTime - currentTime); + player.startTimedHuntingZone(102, transcendent2ExitTime); } - else if ((Transcendent3ExitTime > currentTime) && player.isInTimedHuntingZone(103)) + else if ((transcendent3ExitTime > 0) && player.isInTimedHuntingZone(103)) { - player.startTimedHuntingZone(103, Transcendent3ExitTime - currentTime); + player.startTimedHuntingZone(103, transcendent3ExitTime); } - else if ((Transcendent4ExitTime > currentTime) && player.isInTimedHuntingZone(104)) + else if ((transcendent4ExitTime > 0) && player.isInTimedHuntingZone(104)) { - player.startTimedHuntingZone(104, Transcendent4ExitTime - currentTime); + player.startTimedHuntingZone(104, transcendent4ExitTime); } - else if ((Transcendent6ExitTime > currentTime) && player.isInTimedHuntingZone(106)) + else if ((transcendent6ExitTime > 0) && player.isInTimedHuntingZone(106)) { - player.startTimedHuntingZone(106, Transcendent6ExitTime - currentTime); + player.startTimedHuntingZone(106, transcendent6ExitTime); } - else if ((Transcendent7ExitTime > currentTime) && player.isInTimedHuntingZone(107)) + else if ((transcendent7ExitTime > 0) && player.isInTimedHuntingZone(107)) { - player.startTimedHuntingZone(107, Transcendent7ExitTime - currentTime); + player.startTimedHuntingZone(107, transcendent7ExitTime); } else if (!player.isGM()) { diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index d53759ab76..afba6bc6da 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -78,7 +78,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket player.sendMessage("Cannot use time-limited hunting zones while registered on an event."); return; } - if (player.isInInstance()) + if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY())) { player.sendMessage("Cannot use time-limited hunting zones while in an instance."); return; @@ -95,10 +95,15 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); + final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0); + if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } if (endTime > currentTime) @@ -113,7 +118,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket return; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime); switch (_zoneId) { diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index 55eee234b2..23b5cc8d07 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -20,7 +20,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -56,8 +55,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(1); // zone id packet.writeD(40); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(1); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_PRIMEVAL; @@ -77,8 +80,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(4); // zone id packet.writeD(76); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 4, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(4); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -98,8 +105,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(11); // zone id packet.writeD(60); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(11); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -119,8 +130,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(12); // zone id packet.writeD(80); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(12); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY_ANTHARAS) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_ANTHARAS; @@ -140,8 +155,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(101); // zone id // packet.writeD(40); // min level // packet.writeD(49); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 101, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(101); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -161,8 +180,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(102); // zone id // packet.writeD(50); // min level // packet.writeD(59); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 102, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(102); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -182,8 +205,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(103); // zone id // packet.writeD(60); // min level // packet.writeD(69); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 103, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(103); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -203,8 +230,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(104); // zone id // packet.writeD(70); // min level // packet.writeD(79); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 104, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(104); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -224,8 +255,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(106); // zone id // packet.writeD(80); // min level // packet.writeD(999); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 106, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(106); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -245,8 +280,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(107); // zone id // packet.writeD(85); // min level // packet.writeD(999); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 107, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(107); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index 41e0e929ec..7d376e0c47 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,7 @@ public class AddHuntingTime extends AbstractEffect } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); @@ -91,8 +91,7 @@ public class AddHuntingTime extends AbstractEffect if (player.isInTimedHuntingZone(_zoneId)) { - endTime = _time + player.getTimedHuntingZoneRemainingTime(); - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, _time + player.getTimedHuntingZoneRemainingTime(_zoneId)); player.startTimedHuntingZone(_zoneId, endTime); } else @@ -113,7 +112,7 @@ public class AddHuntingTime extends AbstractEffect { endTime = currentTime; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime + _time); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, (endTime - currentTime) + _time); } player.sendPacket(new TimedHuntingZoneList(player)); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 145cf92b54..8ecb250671 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -361,7 +361,6 @@ import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlaySetting import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo; import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; -import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoPlayTaskManager; import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager; @@ -887,7 +886,7 @@ public class PlayerInstance extends Playable private final AutoPlaySettingsHolder _autoPlaySettings = new AutoPlaySettingsHolder(); private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder(); - private ScheduledFuture _timedHuntingZoneFinishTask = null; + private ScheduledFuture _timedHuntingZoneTask = null; private PlayerRandomCraft _randomCraft = null; @@ -14024,10 +14023,10 @@ public class PlayerInstance extends Playable _fallingDamageTask.cancel(false); _fallingDamageTask = null; } - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isDone() && !_timedHuntingZoneTask.isCancelled()) { - _timedHuntingZoneFinishTask.cancel(false); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; } if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled()) { @@ -14509,34 +14508,39 @@ public class PlayerInstance extends Playable // TODO: Delay window. // sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000))); sendMessage("You have " + (delay / 60 / 1000) + " minutes left for this timed zone."); - _timedHuntingZoneFinishTask = ThreadPool.schedule(() -> + _timedHuntingZoneTask = ThreadPool.scheduleAtFixedRate(() -> { - if ((isOnlineInt() > 0) && isInTimedHuntingZone(zoneId)) + if (isInTimedHuntingZone(zoneId)) { - sendPacket(TimedHuntingZoneExit.STATIC_PACKET); - abortCast(); - stopMove(null); - teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + final long time = getTimedHuntingZoneRemainingTime(zoneId); + if (time > 0) + { + getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + zoneId, time - 60000); + } + else + { + _timedHuntingZoneTask.cancel(false); + _timedHuntingZoneTask = null; + abortCast(); + stopMove(null); + teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN)); + } } - }, delay); + }, 60000, 60000); } public void stopTimedHuntingZoneTask() { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) + if ((_timedHuntingZoneTask != null) && !_timedHuntingZoneTask.isCancelled() && !_timedHuntingZoneTask.isDone()) { - _timedHuntingZoneFinishTask.cancel(true); - _timedHuntingZoneFinishTask = null; + _timedHuntingZoneTask.cancel(true); + _timedHuntingZoneTask = null; } } - public long getTimedHuntingZoneRemainingTime() + public long getTimedHuntingZoneRemainingTime(int zoneId) { - if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone()) - { - return _timedHuntingZoneFinishTask.getDelay(TimeUnit.MILLISECONDS); - } - return 0; + return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0); } private void restoreRandomCraft() diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java index a384d2efb7..bb78ecf215 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java @@ -63,7 +63,8 @@ public class PlayerVariables extends AbstractVariables public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling"; public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat"; public static final String DELUSION_RETURN = "DELUSION_RETURN"; - public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME_"; + public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_"; + public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_"; public static final String SAYHA_GRACE_SUPPORT_ENDTIME = "SAYHA_GRACE_SUPPORT_ENDTIME"; public static final String LIMITED_SAYHA_GRACE_ENDTIME = "LIMITED_SAYHA_GRACE_ENDTIME"; public static final String MAGIC_LAMP_EXP = "MAGIC_LAMP_EXP"; diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java index 190ab2ef14..52bb5bf73b 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java @@ -16,12 +16,10 @@ */ package org.l2jmobius.gameserver.model.zone.type; -import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.MapRegionManager; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit; @@ -44,57 +42,56 @@ public class TimedHuntingZone extends ZoneType { player.setInsideZone(ZoneId.TIMED_HUNTING, true); - final long currentTime = Chronos.currentTimeMillis(); - final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); - final long PrimevalGardenExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 4, 0); - final long AlligatorIslandExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); - final long AntharasLairExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); - final long Transcendent1ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 101, 0); - final long Transcendent2ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 102, 0); - final long Transcendent3ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 103, 0); - final long Transcendent4ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 104, 0); - final long Transcendent6ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 106, 0); - final long Transcendent7ExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 107, 0); + final long primevalIsleExitTime = player.getTimedHuntingZoneRemainingTime(1); + final long primevalGardenExitTime = player.getTimedHuntingZoneRemainingTime(4); + final long alligatorIslandExitTime = player.getTimedHuntingZoneRemainingTime(11); + final long antharasLairExitTime = player.getTimedHuntingZoneRemainingTime(12); + final long transcendent1ExitTime = player.getTimedHuntingZoneRemainingTime(101); + final long transcendent2ExitTime = player.getTimedHuntingZoneRemainingTime(102); + final long transcendent3ExitTime = player.getTimedHuntingZoneRemainingTime(103); + final long transcendent4ExitTime = player.getTimedHuntingZoneRemainingTime(104); + final long transcendent6ExitTime = player.getTimedHuntingZoneRemainingTime(106); + final long transcendent7ExitTime = player.getTimedHuntingZoneRemainingTime(107); - if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(1)) + if ((primevalIsleExitTime > 0) && player.isInTimedHuntingZone(1)) { - player.startTimedHuntingZone(1, primevalIsleExitTime - currentTime); + player.startTimedHuntingZone(1, primevalIsleExitTime); } - else if ((PrimevalGardenExitTime > currentTime) && player.isInTimedHuntingZone(4)) + else if ((primevalGardenExitTime > 0) && player.isInTimedHuntingZone(4)) { - player.startTimedHuntingZone(4, PrimevalGardenExitTime - currentTime); + player.startTimedHuntingZone(4, primevalGardenExitTime); } - else if ((AlligatorIslandExitTime > currentTime) && player.isInTimedHuntingZone(11)) + else if ((alligatorIslandExitTime > 0) && player.isInTimedHuntingZone(11)) { - player.startTimedHuntingZone(11, AlligatorIslandExitTime - currentTime); + player.startTimedHuntingZone(11, alligatorIslandExitTime); } - else if ((AntharasLairExitTime > currentTime) && player.isInTimedHuntingZone(12)) + else if ((antharasLairExitTime > 0) && player.isInTimedHuntingZone(12)) { - player.startTimedHuntingZone(12, AntharasLairExitTime - currentTime); + player.startTimedHuntingZone(12, antharasLairExitTime); } - else if ((Transcendent1ExitTime > currentTime) && player.isInTimedHuntingZone(101)) + else if ((transcendent1ExitTime > 0) && player.isInTimedHuntingZone(101)) { - player.startTimedHuntingZone(101, Transcendent1ExitTime - currentTime); + player.startTimedHuntingZone(101, transcendent1ExitTime); } - else if ((Transcendent2ExitTime > currentTime) && player.isInTimedHuntingZone(102)) + else if ((transcendent2ExitTime > 0) && player.isInTimedHuntingZone(102)) { - player.startTimedHuntingZone(102, Transcendent2ExitTime - currentTime); + player.startTimedHuntingZone(102, transcendent2ExitTime); } - else if ((Transcendent3ExitTime > currentTime) && player.isInTimedHuntingZone(103)) + else if ((transcendent3ExitTime > 0) && player.isInTimedHuntingZone(103)) { - player.startTimedHuntingZone(103, Transcendent3ExitTime - currentTime); + player.startTimedHuntingZone(103, transcendent3ExitTime); } - else if ((Transcendent4ExitTime > currentTime) && player.isInTimedHuntingZone(104)) + else if ((transcendent4ExitTime > 0) && player.isInTimedHuntingZone(104)) { - player.startTimedHuntingZone(104, Transcendent4ExitTime - currentTime); + player.startTimedHuntingZone(104, transcendent4ExitTime); } - else if ((Transcendent6ExitTime > currentTime) && player.isInTimedHuntingZone(106)) + else if ((transcendent6ExitTime > 0) && player.isInTimedHuntingZone(106)) { - player.startTimedHuntingZone(106, Transcendent6ExitTime - currentTime); + player.startTimedHuntingZone(106, transcendent6ExitTime); } - else if ((Transcendent7ExitTime > currentTime) && player.isInTimedHuntingZone(107)) + else if ((transcendent7ExitTime > 0) && player.isInTimedHuntingZone(107)) { - player.startTimedHuntingZone(107, Transcendent7ExitTime - currentTime); + player.startTimedHuntingZone(107, transcendent7ExitTime); } else if (!player.isGM()) { diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index d53759ab76..afba6bc6da 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -78,7 +78,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket player.sendMessage("Cannot use time-limited hunting zones while registered on an event."); return; } - if (player.isInInstance()) + if (player.isInInstance() || player.isInTimedHuntingZone(player.getX(), player.getY())) { player.sendMessage("Cannot use time-limited hunting zones while in an instance."); return; @@ -95,10 +95,15 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket } final long currentTime = Chronos.currentTimeMillis(); - long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId); + final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0); + if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + if (endTime == currentTime) + { + endTime = Config.TIME_LIMITED_ZONE_INITIAL_TIME; + player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime); + } } if (endTime > currentTime) @@ -113,7 +118,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket return; } - player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime); + player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime); switch (_zoneId) { diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index 55eee234b2..23b5cc8d07 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -20,7 +20,6 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; -import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; @@ -56,8 +55,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(1); // zone id packet.writeD(40); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(1); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_PRIMEVAL; @@ -77,8 +80,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(4); // zone id packet.writeD(76); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 4, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(4); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -98,8 +105,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(11); // zone id packet.writeD(60); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(11); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -119,8 +130,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(12); // zone id packet.writeD(80); // min level packet.writeD(999); // max level - packet.writeD(0); // remain time base? - endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + endTime = _player.getTimedHuntingZoneRemainingTime(12); + if (endTime > 0) + { + endTime += currentTime; + } if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY_ANTHARAS) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_ANTHARAS; @@ -140,8 +155,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(101); // zone id // packet.writeD(40); // min level // packet.writeD(49); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 101, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(101); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -161,8 +180,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(102); // zone id // packet.writeD(50); // min level // packet.writeD(59); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 102, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(102); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -182,8 +205,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(103); // zone id // packet.writeD(60); // min level // packet.writeD(69); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 103, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(103); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -203,8 +230,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(104); // zone id // packet.writeD(70); // min level // packet.writeD(79); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 104, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(104); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -224,8 +255,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(106); // zone id // packet.writeD(80); // min level // packet.writeD(999); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 106, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(106); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; @@ -245,8 +280,12 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket // packet.writeD(107); // zone id // packet.writeD(85); // min level // packet.writeD(999); // max level - // packet.writeD(0); // remain time base? - // endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 107, 0); + // packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? + // endTime = _player.getTimedHuntingZoneRemainingTime(107); + // if (endTime > 0) + // { + // endTime += currentTime; + // } // if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) // { // endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;