Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: package net.sf.l2j.gameserver.Restart.java
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver;
- +
- +import java.text.SimpleDateFormat;
- +import java.util.Calendar;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +
- +public class Restart
- +{
- + //Variaveis globais
- + private static Restart _instance = null;
- + protected static final Logger _log = Logger.getLogger(Restart.class.getName());
- + private Calendar NextRestart;
- + private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
- +
- + //Singleton
- + public static Restart getInstance()
- + {
- + if(_instance == null)
- + _instance = new Restart();
- + return _instance;
- + }
- +
- + public String getRestartNextTime()
- + {
- + if(NextRestart.getTime() != null)
- + return format.format(NextRestart.getTime());
- + else
- + return "Erro";
- + }
- +
- + //Connstrutor
- + private Restart()
- + {
- + //:D
- + }
- +
- + public void StartCalculationOfNextRestartTime()
- + {
- + _log.info("#####################################");
- + _log.info("#[Restart System]: System actived...#");
- + _log.info("#####################################");
- + try
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar testStartTime = null;
- + long flush2 = 0,timeL = 0;
- + int count = 0;
- +
- + for (String timeOfDay : Config.RESTART_INTERVAL_BY_TIME_OF_DAY)
- + {
- + testStartTime = Calendar.getInstance();
- + testStartTime.setLenient(true);
- + String[] splitTimeOfDay = timeOfDay.split(":");
- + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
- + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
- + testStartTime.set(Calendar.SECOND, 00);
- + //Verifica a validade to tempo
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + {
- + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
- + }
- +
- + //TimeL Recebe o quanto falta de milisegundos para o restart
- + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
- +
- + //Verifica qual horario sera o proximo restart
- + if(count == 0){
- + flush2 = timeL;
- + NextRestart = testStartTime;
- + }
- +
- + if(timeL < flush2){
- + flush2 = timeL;
- + NextRestart = testStartTime;
- + }
- +
- + count ++;
- + }
- + _log.info("[AutoRestart]: Next Restart Time: " + NextRestart.getTime().toString());
- + ThreadPool.schedule(new StartRestartTask(), flush2);
- + }
- + catch (Exception e)
- + {
- + System.out.println("[AutoRestart]: The restart automated server presented error in load restarts period config !");
- + }
- + }
- +
- + class StartRestartTask implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + _log.info("Start automated restart GameServer.");
- + Shutdown.getInstance().autoRestart(Config.RESTART_SECONDS);
- + }
- + }
- +}
- Index: package net/sf/l2j/gameserver/Shutdown.java
- private static class SingletonHolder
- {
- protected static final Shutdown _instance = new Shutdown();
- }
- + public void autoRestart(int time)
- + {
- + _secondsShut = time;
- +
- + countdown();
- +
- + _shutdownMode = GM_RESTART;
- +
- + SingletonHolder._instance.setMode(GM_RESTART);
- + System.exit(2);
- + }
- Index: package net/sf/l2j/gameserver/GameServer.java
- Util.printSection("World Bosses");
- GrandBossManager.getInstance();
- +if(Config.RESTART_BY_TIME_OF_DAY)
- +Restart.getInstance().StartCalculationOfNextRestartTime();
- +else
- +_log.info("# Auto Restart System is Disabled #");
- Index: package net/sf/l2j/Config.java
- public static int MONSTER_LOCS_COUNT;
- public static int[][] MONSTER_LOCS;
- + public static boolean RESTART_BY_TIME_OF_DAY;
- + public static int RESTART_SECONDS;
- + public static String[] RESTART_INTERVAL_BY_TIME_OF_DAY;
- ALT_GIVE_PVP_IN_ARENA = L2JDev.getProperty("AltGivePvpInArena", false);
- SHOW_HP_PVP = L2JDev.getProperty("ShowHpPvP", false);
- + RESTART_BY_TIME_OF_DAY = Boolean.parseBoolean(L2JDev.getProperty("EnableRestartSystem", "false"));
- + RESTART_SECONDS = Integer.parseInt(L2JDev.getProperty("RestartSeconds", "360"));
- + RESTART_INTERVAL_BY_TIME_OF_DAY = L2JDev.getProperty("RestartByTimeOfDay", "20:00").split(",");
- Index: package net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- import net.sf.l2j.gameserver.GameTimeController;
- +import net.sf.l2j.gameserver.Restart;
- SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
- AnnouncementTable.getInstance().showAnnouncements(activeChar, false);
- + if(Config.RESTART_BY_TIME_OF_DAY)
- + {
- + ShowNextRestart(activeChar);
- + }
- + private static void ShowNextRestart(Player activeChar)
- + {
- + activeChar.sendMessage("Next Restart: " + Restart.getInstance().getRestartNextTime());
- + }
- private void onEnterPin(Player activeChar)
- {
- String last = "";
- String curr = "";
- try
- {
- last = LastIP(activeChar);
- Index: pasta datapack sua revisão caminho -> gameserver\config\L2JDev.properties
- #=============================================================
- # Healer Party Restrictions
- #=============================================================
- # Max Bishop, Cardinal, Elder, etc per PARTY
- MaxHealerOnParty = 2
- # Max Dominator per PARTY
- MaxCombatHealerOnParty = 3
- +#======================================================
- +# Auto Restart
- +#======================================================
- +# Enable / Disable Restart Auto
- +EnableRestartSystem = True
- +
- +# If EnableRestartSystem = True hours of the day
- +# Example: 22:00,23:00 (hh:mm,hh:mm...)
- +# NOTE: Separate ":" mm:hh and "," others restart time
- +RestartByTimeOfDay = 00:00
- +
- +# Seconds to restart the server ( 360 = 5 Minutos )
- +# default = 30, Max 360
- +RestartSeconds = 30
Add Comment
Please, Sign In to add comment