Anyone that can test this?
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 c05ed78..d6d31ac 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 @@
}
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 @@
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 @@
{
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 9d5f5e3..26b5b06 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
@@ -351,7 +351,6 @@
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
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.PlayerAutoSaveTaskManager;
import org.l2jmobius.gameserver.taskmanager.PvpFlagTaskManager;
@@ -877,7 +876,7 @@
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;
@@ -14058,10 +14057,10 @@
_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())
{
@@ -14339,7 +14338,6 @@
{
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
@@ -14378,34 +14376,39 @@
// 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 6ad0ea3..a44cb13 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 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 eab3320..bc015e3 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 @@
{
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 e246720..8af824c 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 @@
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 @@
}
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 @@
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 e39e9b3..158f48f 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.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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;