Addition of MaximumAddedTime configuration.

This commit is contained in:
MobiusDevelopment 2020-01-23 17:40:42 +00:00
parent e44125f798
commit 04d2ed51da
8 changed files with 37 additions and 11 deletions

View File

@ -6,6 +6,10 @@
# Default: 3600000 (1 hour)
InitialTime = 3600000
# Maximum added time.
# Default: 18000000 (5 hours)
MaximumAddedTime = 18000000
# Reset delay.
# Default: 36000000 (10 hours)
ResetDelay = 36000000

View File

@ -56,15 +56,22 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, false);
player.sendMessage("You cannot exceed the time zone limit.");
return;
}
if (player.isInTimedHuntingZone(_zoneId))
{
final long increasedTime = _time + player.getTimedHuntingZoneRemainingTime();
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + increasedTime);
player.startTimedHuntingZone(_zoneId, increasedTime);
endTime = _time + player.getTimedHuntingZoneRemainingTime();
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime);
player.startTimedHuntingZone(_zoneId, endTime);
}
else
{
long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0);
if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime)
{
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;

View File

@ -817,6 +817,7 @@ public class Config
public static List<String> TELNET_HOSTS;
public static int TELNET_PORT;
public static long TIME_LIMITED_ZONE_INITIAL_TIME;
public static long TIME_LIMITED_MAX_ADDED_TIME;
public static long TIME_LIMITED_ZONE_RESET_DELAY;
public static long TIME_LIMITED_ZONE_TELEPORT_FEE;
public static boolean TRAINING_CAMP_ENABLE;
@ -1980,6 +1981,7 @@ public class Config
final PropertiesParser timeLimitedZoneSettings = new PropertiesParser(TIME_LIMITED_ZONE_CONFIG_FILE);
TIME_LIMITED_ZONE_INITIAL_TIME = timeLimitedZoneSettings.getLong("InitialTime", 3600000);
TIME_LIMITED_MAX_ADDED_TIME = timeLimitedZoneSettings.getLong("MaximumAddedTime", 18000000);
TIME_LIMITED_ZONE_RESET_DELAY = timeLimitedZoneSettings.getLong("ResetDelay", 36000000);
TIME_LIMITED_ZONE_TELEPORT_FEE = timeLimitedZoneSettings.getLong("TeleportFee", 150000);

View File

@ -62,7 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;
}
packet.writeD((int) (Math.max(endTime - currentTime, 0)) / 1000); // remain time
packet.writeD(18000); // TODO: remain time max
packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME / 1000));
packet.writeD(3600); // remain refill time
packet.writeD(3600); // refill time max
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated
@ -82,7 +82,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;
}
packet.writeD((int) (Math.max(endTime - currentTime, 0)) / 1000); // remain time
packet.writeD(18000); // TODO: remain time max
packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME / 1000));
packet.writeD(3600); // remain refill time
packet.writeD(3600); // refill time max
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated

View File

@ -6,6 +6,10 @@
# Default: 3600000 (1 hour)
InitialTime = 3600000
# Maximum added time.
# Default: 18000000 (5 hours)
MaximumAddedTime = 18000000
# Reset delay.
# Default: 36000000 (10 hours)
ResetDelay = 36000000

View File

@ -56,15 +56,22 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, false);
player.sendMessage("You cannot exceed the time zone limit.");
return;
}
if (player.isInTimedHuntingZone(_zoneId))
{
final long increasedTime = _time + player.getTimedHuntingZoneRemainingTime();
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + increasedTime);
player.startTimedHuntingZone(_zoneId, increasedTime);
endTime = _time + player.getTimedHuntingZoneRemainingTime();
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, currentTime + endTime);
player.startTimedHuntingZone(_zoneId, endTime);
}
else
{
long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0);
if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime)
{
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;

View File

@ -811,6 +811,7 @@ public class Config
public static List<String> TELNET_HOSTS;
public static int TELNET_PORT;
public static long TIME_LIMITED_ZONE_INITIAL_TIME;
public static long TIME_LIMITED_MAX_ADDED_TIME;
public static long TIME_LIMITED_ZONE_RESET_DELAY;
public static long TIME_LIMITED_ZONE_TELEPORT_FEE;
public static boolean TRAINING_CAMP_ENABLE;
@ -1861,6 +1862,7 @@ public class Config
final PropertiesParser timeLimitedZoneSettings = new PropertiesParser(TIME_LIMITED_ZONE_CONFIG_FILE);
TIME_LIMITED_ZONE_INITIAL_TIME = timeLimitedZoneSettings.getLong("InitialTime", 3600000);
TIME_LIMITED_MAX_ADDED_TIME = timeLimitedZoneSettings.getLong("MaximumAddedTime", 18000000);
TIME_LIMITED_ZONE_RESET_DELAY = timeLimitedZoneSettings.getLong("ResetDelay", 36000000);
TIME_LIMITED_ZONE_TELEPORT_FEE = timeLimitedZoneSettings.getLong("TeleportFee", 10000);

View File

@ -62,7 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;
}
packet.writeD((int) (Math.max(endTime - currentTime, 0)) / 1000); // remain time
packet.writeD(18000); // TODO: remain time max
packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME / 1000));
packet.writeD(3600); // remain refill time
packet.writeD(3600); // refill time max
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated