Server restart schedule by day.
This commit is contained in:
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -762,6 +762,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1411,6 +1412,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -769,6 +769,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1418,6 +1419,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -770,6 +770,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1431,6 +1432,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -757,6 +757,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1418,6 +1419,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -752,6 +752,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1413,6 +1414,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -752,6 +752,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1413,6 +1414,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -753,6 +753,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1435,6 +1436,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -752,6 +752,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Hardin (Agent of Chaos)
|
// Hardin (Agent of Chaos)
|
||||||
@@ -1436,6 +1437,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -204,3 +204,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -888,6 +888,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// MMO Settings
|
// MMO Settings
|
||||||
@@ -1468,6 +1469,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -204,3 +204,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -893,6 +893,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// MMO Settings
|
// MMO Settings
|
||||||
@@ -1469,6 +1470,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -760,6 +760,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1351,6 +1352,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -760,6 +760,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1355,6 +1356,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -760,6 +760,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1355,6 +1356,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -760,6 +760,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1355,6 +1356,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -760,6 +760,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1360,6 +1361,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -759,6 +759,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1359,6 +1360,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
@@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600
|
|||||||
# You can put more than one value separated by commas (,).
|
# You can put more than one value separated by commas (,).
|
||||||
# Example: 12:00, 00:00
|
# Example: 12:00, 00:00
|
||||||
ServerRestartSchedule = 08:00
|
ServerRestartSchedule = 08:00
|
||||||
|
|
||||||
|
# Specify days that the restart will occur. Values separated by commas (,).
|
||||||
|
# Example: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||||
|
# Default: 4 (WEDNESDAY)
|
||||||
|
ServerRestartDays = 4
|
||||||
|
|||||||
@@ -762,6 +762,7 @@ public class Config
|
|||||||
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
public static boolean SERVER_RESTART_SCHEDULE_MESSAGE;
|
||||||
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
public static int SERVER_RESTART_SCHEDULE_COUNTDOWN;
|
||||||
public static String[] SERVER_RESTART_SCHEDULE;
|
public static String[] SERVER_RESTART_SCHEDULE;
|
||||||
|
public static List<Integer> SERVER_RESTART_DAYS;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// Vitality Settings
|
// Vitality Settings
|
||||||
@@ -1362,6 +1363,14 @@ public class Config
|
|||||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||||
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
SERVER_RESTART_SCHEDULE = serverSettings.getString("ServerRestartSchedule", "08:00").split(",");
|
||||||
|
SERVER_RESTART_DAYS = new ArrayList<>();
|
||||||
|
for (String day : serverSettings.getString("ServerRestartDays", "").trim().split(","))
|
||||||
|
{
|
||||||
|
if (Util.isDigit(day))
|
||||||
|
{
|
||||||
|
SERVER_RESTART_DAYS.add(Integer.parseInt(day));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hosts and Subnets
|
// Hosts and Subnets
|
||||||
final IPConfigData ipcd = new IPConfigData();
|
final IPConfigData ipcd = new IPConfigData();
|
||||||
|
|||||||
+46
-3
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
|||||||
import org.l2jmobius.gameserver.Shutdown;
|
import org.l2jmobius.gameserver.Shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gigi
|
* @author Gigi, Mobius
|
||||||
*/
|
*/
|
||||||
public class ServerRestartManager
|
public class ServerRestartManager
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,15 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
if (restartTime.getTimeInMillis() < currentTime.getTimeInMillis())
|
||||||
{
|
{
|
||||||
restartTime.add(Calendar.DAY_OF_MONTH, 1);
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
while (!Config.SERVER_RESTART_DAYS.contains(restartTime.get(Calendar.DAY_OF_WEEK)))
|
||||||
|
{
|
||||||
|
restartTime.add(Calendar.DAY_OF_WEEK, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
delay = restartTime.getTimeInMillis() - currentTime.getTimeInMillis();
|
||||||
@@ -70,7 +79,14 @@ public class ServerRestartManager
|
|||||||
|
|
||||||
if (lastRestart != null)
|
if (lastRestart != null)
|
||||||
{
|
{
|
||||||
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
if (Config.SERVER_RESTART_DAYS.isEmpty())
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextRestartTime = new SimpleDateFormat("MMMM d'" + getDayNumberSuffix(lastRestart.get(Calendar.DAY_OF_MONTH)) + "' HH:mm", Locale.UK).format(lastRestart.getTime());
|
||||||
|
}
|
||||||
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
ThreadPool.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
|
||||||
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
LOGGER.info("Scheduled server restart at " + lastRestart.getTime() + ".");
|
||||||
}
|
}
|
||||||
@@ -81,6 +97,33 @@ public class ServerRestartManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayNumberSuffix(int day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 21:
|
||||||
|
case 31:
|
||||||
|
{
|
||||||
|
return "st";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
case 22:
|
||||||
|
{
|
||||||
|
return "nd";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
case 23:
|
||||||
|
{
|
||||||
|
return "rd";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "th";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNextRestartTime()
|
public String getNextRestartTime()
|
||||||
{
|
{
|
||||||
return nextRestartTime;
|
return nextRestartTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user