warc222

Sitorestart

Aug 30th, 2022
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.26 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2JFrozen
  3. Index: gameserver/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  4. ===================================================================
  5. --- gameserver/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (revision 936)
  6. +++ gameserver/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (working copy)
  7. @@ -26,6 +26,7 @@
  8. import com.l2jfrozen.Config;
  9. import com.l2jfrozen.crypt.nProtect;
  10. import com.l2jfrozen.crypt.nProtect.RestrictionType;
  11. +import com.l2jfrozen.gameserver.Restart;
  12. import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager;
  13. import com.l2jfrozen.gameserver.controllers.GameTimeController;
  14. import com.l2jfrozen.gameserver.datatables.CharSchemesTable;
  15. @@ -466,6 +467,11 @@
  16. }
  17. }
  18.  
  19. + if(Config.RESTART_BY_TIME_OF_DAY)
  20. + {
  21. + ShowNextRestart(activeChar);
  22. + }
  23. +
  24. // NPCBuffer
  25. if (PowerPakConfig.BUFFER_ENABLED)
  26. CharSchemesTable.getInstance().onPlayerLogin(activeChar.getObjectId());
  27. @@ -801,6 +807,17 @@
  28. }
  29. }
  30.  
  31. + /**
  32. + * Envia mensagem para o player do proximo restart
  33. + * NOTE: RESTART_BY_TIME_OF_DAY = TRUE
  34. + *
  35. + * @param activeChar
  36. + */
  37. + private void ShowNextRestart(L2PcInstance activeChar)
  38. + {
  39. + activeChar.sendMessage("Next Restart: " + Restart.getInstance().getRestartNextTime());
  40. + }
  41. +
  42. @Override
  43. public String getType()
  44. {
  45.  
  46.  
  47.  
  48. ### Eclipse Workspace Patch 1.0
  49. #P L2JFrozen
  50. Index: gameserver/head-src/com/l2jfrozen/gameserver/Shutdown.java
  51. ===================================================================
  52. --- gameserver/head-src/com/l2jfrozen/gameserver/Shutdown.java (revision 936)
  53. +++ gameserver/head-src/com/l2jfrozen/gameserver/Shutdown.java (working copy)
  54. @@ -171,6 +171,18 @@
  55. }
  56. }
  57.  
  58. + public void autoRestart(int time)
  59. + {
  60. + _secondsShut = time;
  61. +
  62. + countdown();
  63. +
  64. + _shutdownMode = GM_RESTART;
  65. +
  66. + _instance.setMode(GM_RESTART);
  67. + System.exit(2);
  68. + }
  69. +
  70. /**
  71. * Default constucter is only used internal to create the shutdown-hook instance
  72. */
  73.  
  74.  
  75. ### Eclipse Workspace Patch 1.0
  76. #P L2JFrozen
  77. Index: gameserver/head-src/com/l2jfrozen/gameserver/Restart.java
  78. ===================================================================
  79. --- gameserver/head-src/com/l2jfrozen/gameserver/Restart.java (revision 0)
  80. +++ gameserver/head-src/com/l2jfrozen/gameserver/Restart.java (revision 0)
  81. @@ -0,0 +1,122 @@
  82. +/*
  83. + * This program is free software: you can redistribute it and/or modify it under
  84. + * the terms of the GNU General Public License as published by the Free Software
  85. + * Foundation, either version 3 of the License, or (at your option) any later
  86. + * version.
  87. + *
  88. + * This program is distributed in the hope that it will be useful, but WITHOUT
  89. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  90. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  91. + * details.
  92. + *
  93. + * You should have received a copy of the GNU General Public License along with
  94. + * this program. If not, see <http://www.gnu.org/licenses/>.
  95. + */
  96. + package com.l2jfrozen.gameserver;
  97. +
  98. + import java.text.SimpleDateFormat;
  99. + import java.util.Calendar;
  100. + import java.util.logging.Logger;
  101. +
  102. + import com.l2jfrozen.Config;
  103. + import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  104. +
  105. + /**
  106. + * This Config for Auto Restart GameServer
  107. + * Initialize class getInstance()
  108. + * Set Time in Config File
  109. + * Thank You L2JServer | L2JRussia
  110. + *
  111. + * @author L2JRussia
  112. + *
  113. + */
  114. + public class Restart
  115. + {
  116. + //Variaveis globais
  117. + private static Restart _instance = null;
  118. + protected static final Logger _log = Logger.getLogger(Restart.class.getName());
  119. + private Calendar NextRestart;
  120. + private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  121. +
  122. + //Singleton
  123. + public static Restart getInstance()
  124. + {
  125. + if(_instance == null)
  126. + _instance = new Restart();
  127. + return _instance;
  128. + }
  129. +
  130. + public String getRestartNextTime()
  131. + {
  132. + if(NextRestart.getTime() != null)
  133. + return format.format(NextRestart.getTime());
  134. + else
  135. + return "Erro";
  136. + }
  137. +
  138. + //Connstrutor
  139. + private Restart()
  140. + {
  141. + //:D
  142. + }
  143. +
  144. + public void StartCalculationOfNextRestartTime()
  145. + {
  146. + _log.info("#####################################");
  147. + _log.info("#[Restart System]: System actived...#");
  148. + _log.info("#####################################");
  149. + try
  150. + {
  151. + Calendar currentTime = Calendar.getInstance();
  152. + Calendar testStartTime = null;
  153. + long flush2 = 0,timeL = 0;
  154. + int count = 0;
  155. +
  156. + for (String timeOfDay : Config.RESTART_INTERVAL_BY_TIME_OF_DAY)
  157. + {
  158. + testStartTime = Calendar.getInstance();
  159. + testStartTime.setLenient(true);
  160. + String[] splitTimeOfDay = timeOfDay.split(":");
  161. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  162. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  163. + testStartTime.set(Calendar.SECOND, 00);
  164. + //Verifica a validade to tempo
  165. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  166. + {
  167. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  168. + }
  169. +
  170. + //TimeL Recebe o quanto falta de milisegundos para o restart
  171. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  172. +
  173. + //Verifica qual horario sera o proximo restart
  174. + if(count == 0){
  175. + flush2 = timeL;
  176. + NextRestart = testStartTime;
  177. + }
  178. +
  179. + if(timeL < flush2){
  180. + flush2 = timeL;
  181. + NextRestart = testStartTime;
  182. + }
  183. +
  184. + count ++;
  185. + }
  186. + _log.info("[AutoRestart]: Next Restart Time: " + NextRestart.getTime().toString());
  187. + ThreadPoolManager.getInstance().scheduleGeneral(new StartRestartTask(), flush2);
  188. + }
  189. + catch (Exception e)
  190. + {
  191. + System.out.println("[AutoRestart]: The restart automated server presented error in load restarts period config !");
  192. + }
  193. + }
  194. +
  195. + class StartRestartTask implements Runnable
  196. + {
  197. + public void run()
  198. + {
  199. + _log.info("Start automated restart GameServer.");
  200. + Shutdown.getInstance().autoRestart(Config.RESTART_SECONDS);
  201. + }
  202. + }
  203. + }
  204. \ No newline at end of file
  205.  
  206.  
  207. ### Eclipse Workspace Patch 1.0
  208. #P L2JFrozen
  209. Index: gameserver/head-src/com/l2jfrozen/gameserver/GameServer.java
  210. ===================================================================
  211. --- gameserver/head-src/com/l2jfrozen/gameserver/GameServer.java (revision 936)
  212. +++ gameserver/head-src/com/l2jfrozen/gameserver/GameServer.java (working copy)
  213. @@ -549,6 +549,14 @@
  214. if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
  215. OfflineTradeTable.restoreOfflineTraders();
  216.  
  217. + Util.printSection("Restart Manager");
  218. + if(Config.RESTART_BY_TIME_OF_DAY)
  219. + Restart.getInstance().StartCalculationOfNextRestartTime();
  220. + else
  221. + _log.info("# Auto Restart System is Disabled #");
  222. +
  223. + System.gc();
  224. +
  225. Util.printSection("Info");
  226. _log.info("Operating System: " + Util.getOSName() + " " + Util.getOSVersion() + " " + Util.getOSArch());
  227. _log.info("Available CPUs: " + Util.getAvailableProcessors());
  228.  
  229.  
  230.  
  231. ### Eclipse Workspace Patch 1.0
  232. #P L2JFrozen
  233. Index: gameserver/config/custom/la2slipper.properties
  234. ===================================================================
  235. --- gameserver/config/functions/l2jfrozen.properties (revision 979)
  236. +++ gameserver/config/functions/l2jfrozen.properties (working copy)
  237. @@ -2,6 +2,42 @@
  238. # Server Config #
  239. #============================================================#
  240.  
  241. +###########################################
  242. +# Automated restart config #
  243. +# l2frozen mod #
  244. +# #########################################
  245. +# Enable / Disable Restart Auto
  246. +EnableRestartSystem = False
  247. +
  248. +# If EnableRestartSystem = True Describe hours of the day
  249. +# Example: 22:00,23:00 (hh:mm,hh:mm...)
  250. +# NOTE: Separate ":" mm:hh and "," others restart time
  251. +RestartByTimeOfDay = 00:00,12:00
  252. +
  253. +# Seconds to restart the server ( 360 = 5 Minutos )
  254. +# default = 360
  255. +RestartSeconds = 360
  256. +
  257. # Server Name Enabled: Displays a message on char login
  258. # with the server name you have set below.
  259. ServerNameEnabled = False
  260.  
  261. ### Eclipse Workspace Patch 1.0
  262. #P L2JFrozen
  263. Index: gameserver/head-src/com/l2jfrozen/Config.java
  264. ===================================================================
  265. --- gameserver/head-src/com/l2jfrozen/Config.java (revision 936)
  266. +++ gameserver/head-src/com/l2jfrozen/Config.java (working copy)
  267.  
  268. @@ -2281,6 +2287,13 @@
  269. public static boolean ANNOUNCE_TO_ALL_SPAWN_RB;
  270. public static boolean ANNOUNCE_TRY_BANNED_ACCOUNT;
  271. public static String ALT_Server_Name;
  272. + public static boolean ENABLE_CLAN_SYSTEM;
  273. + public static Map CLAN_SKILLS;
  274. + public static byte CLAN_LEVEL;
  275. + public static int REPUTATION_QUANTITY;
  276. + public static boolean RESTART_BY_TIME_OF_DAY;
  277. + public static int RESTART_SECONDS;
  278. + public static String[] RESTART_INTERVAL_BY_TIME_OF_DAY;
  279.  
  280. ---------------------------------------------------------------------------------------------------------
  281.  
  282. /** Server Name **/
  283. ALT_SERVER_NAME_ENABLED = Boolean.parseBoolean(L2JFrozenSettings.getProperty("ServerNameEnabled", "false"));
  284. ANNOUNCE_TO_ALL_SPAWN_RB = Boolean.parseBoolean(L2JFrozenSettings.getProperty("AnnounceToAllSpawnRb", "false"));
  285. ANNOUNCE_TRY_BANNED_ACCOUNT = Boolean.parseBoolean(L2JFrozenSettings.getProperty("AnnounceTryBannedAccount", "false"));
  286. ALT_Server_Name = String.valueOf(L2JFrozenSettings.getProperty("ServerName"));
  287. + RESTART_BY_TIME_OF_DAY = Boolean.parseBoolean(la2slipperSettings.getProperty("EnableRestartSystem", "false"));
  288. + RESTART_SECONDS = Integer.parseInt(la2slipperSettings.getProperty("RestartSeconds", "360"));
  289. + RESTART_INTERVAL_BY_TIME_OF_DAY = la2slipperSettings.getProperty("RestartByTimeOfDay", "20:00").split(",");
  290.  
Add Comment
Please, Sign In to add comment