Example #1
0
        private static void OnTimerTick(object sender, EventArgs e)
        {
            MainWindow main = ((MainWindow)Application.Current.MainWindow);

            if (main.Debug)
            {
                OutputHandler.Log($"Running: {running} Failed attempts: {failedAttempts}");
            }

            if (running)
            {
                failedAttempts = 0;
            }
            else
            {
                if (failedAttempts == 60)
                {
                    OutputHandler.Log("Server is idle... checking if it's still responding!", Level.WARN);
                    CommandExecutor.Command("list");
                }
                if (failedAttempts >= 90)
                {
                    OutputHandler.Log("Server has not responded in a long time! Restarting...", Level.WARN);
                    main.JavaServer.Stop();
                    main.JavaServer.Start();
                    failedAttempts = 0;
                }
                else
                {
                    failedAttempts++;
                }
            }
            running = false;
        }
Example #2
0
        public static void Load()
        {
            try
            {
                MainWindow main          = ((MainWindow)(Application.Current.MainWindow));
                string     xms           = ConfigHandler.Startup.Items[0];
                string     xmx           = ConfigHandler.Startup.Items[1];
                string     serverJarPath = ConfigHandler.Startup.Items[2];
                bool       autoStart     = Convert.ToBoolean(ConfigHandler.Startup.Items[3]);
                main.inputXMS.Text               = xms;
                main.inputXMX.Text               = xmx;
                main.inputJarLocation.Text       = serverJarPath;
                main.checkboxAutoStart.IsChecked = autoStart;

                Xms           = xms;
                Xmx           = xmx;
                ServerJarPath = serverJarPath;
                AutoStart     = autoStart;
            }
            catch (Exception ex)
            {
                if (ex is NullReferenceException)
                {
                    ConfigHandler.SetDefault();
                }
                else
                {
                    OutputHandler.Log(ex.ToString(), Level.ERROR);
                }
            }
        }
Example #3
0
 public static void Load()
 {
     try
     {
         ConfigItem json = JsonConvert.DeserializeObject <ConfigItem>(File.ReadAllText(file));
         Startup = json;
     }
     catch (Exception ex)
     {
         OutputHandler.Log(ex.Message);
     }
 }