From 6a1f4c21accdeb7d67c04b7b2fb2073f90af380e Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 15 Jan 2020 10:01:39 +0000 Subject: [PATCH] Server restart schedule by day. --- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- .../dist/game/config/Server.ini | 5 ++ .../java/org/l2jmobius/Config.java | 11 ++++- .../instancemanager/ServerRestartManager.java | 49 +++++++++++++++++-- 51 files changed, 1037 insertions(+), 68 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini index cf1e5f042d..59789eece7 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini +++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java index 3a4b61abd5..f07202db51 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java @@ -762,6 +762,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1288,7 +1289,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1411,6 +1412,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini b/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini index 7b7929c63f..436cf18c0d 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini +++ b/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java index 9f2bf9dbba..40759dc1f1 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java @@ -769,6 +769,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1295,7 +1296,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1418,6 +1419,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini b/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini index 30a3df29e4..a3151947cf 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini +++ b/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java index 1b7b185382..cfff6d8bde 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java @@ -770,6 +770,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1308,7 +1309,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1431,6 +1432,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini index d11cfa4f56..f45a814eb5 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java index 185859b3ff..ffe499b5a3 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java @@ -757,6 +757,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1295,7 +1296,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1418,6 +1419,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini b/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini index e15a65adb0..7696505c68 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini +++ b/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java index c777bbd6e8..bf44f11cb4 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java @@ -752,6 +752,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1290,7 +1291,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1413,6 +1414,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini index accb46c074..79a7f050d7 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java index c777bbd6e8..bf44f11cb4 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java @@ -752,6 +752,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1290,7 +1291,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1413,6 +1414,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini b/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini index a9e0fb852f..601f615c07 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini +++ b/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java index ca6ba918a3..1ec8e4d419 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java @@ -753,6 +753,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1312,7 +1313,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1435,6 +1436,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini index 394daf7164..e1a4c5daf6 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java index 2d9b8940a5..d9cad9e634 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java @@ -752,6 +752,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Hardin (Agent of Chaos) @@ -1313,7 +1314,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1436,6 +1437,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini index a9da446b65..a66dbc8d76 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini @@ -204,3 +204,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java index 17db6a4c2a..c456ada1b2 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java @@ -888,6 +888,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // MMO Settings @@ -1348,7 +1349,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in config file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (config file) for configuring your server. @@ -1468,6 +1469,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini index 7601152b0b..3cc6e0ddab 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini @@ -204,3 +204,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java index 0343b75c29..81f7c8eedb 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java @@ -893,6 +893,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // MMO Settings @@ -1349,7 +1350,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in config file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (config file) for configuring your server. @@ -1469,6 +1470,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini index 284241b3a5..cd09a117ca 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java index 21e551fddd..26e4dd1874 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java @@ -760,6 +760,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1228,7 +1229,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1351,6 +1352,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini index a60aa6a905..f5838f68f4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java index 537caec6c8..2d73395e60 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java @@ -760,6 +760,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1232,7 +1233,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1355,6 +1356,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini index c45190e47c..b7162e8ec8 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java index 537caec6c8..2d73395e60 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java @@ -760,6 +760,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1232,7 +1233,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1355,6 +1356,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini index c7256eb6d5..ade390d12d 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java index 537caec6c8..2d73395e60 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java @@ -760,6 +760,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1232,7 +1233,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1355,6 +1356,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini index 1cd02d9622..a1c00e4038 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java index e5a9b39ef5..741fe5cece 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java @@ -760,6 +760,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1237,7 +1238,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1360,6 +1361,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini index 352f1d6e0c..4ffd653190 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java index 9b019f2bb9..ecfc01daef 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java @@ -759,6 +759,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1236,7 +1237,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1359,6 +1360,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime; diff --git a/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini b/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini index 8e3502a361..8f08a822e5 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini @@ -220,3 +220,8 @@ ServerRestartScheduleCountdown = 600 # You can put more than one value separated by commas (,). # Example: 12:00, 00: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 diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java index fbdda9f835..dc1e399011 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java @@ -762,6 +762,7 @@ public class Config public static boolean SERVER_RESTART_SCHEDULE_MESSAGE; public static int SERVER_RESTART_SCHEDULE_COUNTDOWN; public static String[] SERVER_RESTART_SCHEDULE; + public static List SERVER_RESTART_DAYS; // -------------------------------------------------- // Vitality Settings @@ -1239,7 +1240,7 @@ public class Config public static Map L2TOP_REWARD = new HashMap<>(); public static int L2TOP_DUALBOXES_ALLOWED; public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT; - + /** * This class initializes all global variables for configuration.
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server. @@ -1362,6 +1363,14 @@ public class Config SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false); SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600); 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 final IPConfigData ipcd = new IPConfigData(); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java index 41d3024ccf..8a0e93eaf4 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ServerRestartManager.java @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.logging.Logger; import org.l2jmobius.Config; @@ -25,7 +26,7 @@ import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.gameserver.Shutdown; /** - * @author Gigi + * @author Gigi, Mobius */ public class ServerRestartManager { @@ -52,7 +53,15 @@ public class ServerRestartManager 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(); @@ -70,7 +79,14 @@ public class ServerRestartManager 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)); 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() { return nextRestartTime;