Example #1
0
 public static void Exec() //Dictionary keys in schedule correspond to specific class in order to execute corresponding methods
 {
     try
     {
         foreach (var _event in Schedule.ToArray())
         {
             if (DateTime.Now >= _event.Value)
             {
                 if (_event.Key == "AutoBackup")
                 {
                     Add("AutoBackup", DateTime.Now.AddMinutes(AutoBackup.Delay));
                     AutoBackup.Exec();
                 }
                 else if (_event.Key == "AutoSaveWorld")
                 {
                     Add("AutoSaveWorld", DateTime.Now.AddMinutes(AutoSaveWorld.Delay));
                     AutoSaveWorld.Save();
                 }
                 else if (_event.Key == "Bloodmoon")
                 {
                     Add("Bloodmoon", DateTime.Now.AddMinutes(Bloodmoon.Delay));
                     Bloodmoon.StatusCheck();
                 }
                 else if (_event.Key == "BreakTime")
                 {
                     Add("BreakTime", DateTime.Now.AddMinutes(BreakTime.Delay));
                     BreakTime.Exec();
                 }
                 else if (_event.Key == "InfoTicker")
                 {
                     Add("InfoTicker", DateTime.Now.AddMinutes(InfoTicker.Delay));
                     InfoTicker.Exec();
                 }
                 else if (_event.Key == "NightAlert")
                 {
                     Add("NightAlert", DateTime.Now.AddMinutes(NightAlert.Delay));
                     NightAlert.Exec();
                 }
                 else if (_event.Key == "PlayerLogs")
                 {
                     Add("PlayerLogs", DateTime.Now.AddMinutes(PlayerLogs.Delay));
                     PlayerLogs.Exec();
                 }
                 else if (_event.Key == "RealWorldTime")
                 {
                     Add("RealWorldTime", DateTime.Now.AddMinutes(RealWorldTime.Delay));
                     RealWorldTime.Exec();
                 }
                 else if (_event.Key == "Watchlist")
                 {
                     Add("Watchlist", DateTime.Now.AddMinutes(Watchlist.Delay));
                     Watchlist.CheckWatchlist();
                 }
                 else if (_event.Key == "Zones")
                 {
                     Add("Zones", DateTime.Now.AddMinutes(Zones.Reminder_Delay));
                     Zones.ReminderExec();
                 }
                 else if (_event.Key == "Shutdown") //combines stop server tool to apply a countdown timer before shutdown
                 {
                     StopServer.PrepareShutdown();
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in EventSchedule.Exec: {0}", e.Message));
     }
 }
Example #2
0
        public static void Exec()
        {
            try
            {
                if (Schedule.Count > 0)
                {
                    foreach (var entry in Schedule.ToArray())
                    {
                        switch (entry.Key)
                        {
                        case "AutoBackup":
                            if (DateTime.Now >= entry.Value)
                            {
                                autoBackup = "";
                                AutoBackup.SetDelay();
                                AutoBackup.Exec();
                            }
                            continue;

                        case "AutoSaveWorld":
                            if (DateTime.Now >= entry.Value)
                            {
                                autoSaveWorld = "";
                                AutoSaveWorld.SetDelay();
                                AutoSaveWorld.Save();
                            }
                            continue;

                        case "Bloodmoon":
                            if (DateTime.Now >= entry.Value)
                            {
                                bloodmoon = "";
                                Bloodmoon.SetDelay();
                                Bloodmoon.StatusCheck();
                            }
                            continue;

                        case "BreakTime":
                            if (DateTime.Now >= entry.Value)
                            {
                                breakTime = "";
                                BreakTime.SetDelay();
                                BreakTime.Exec();
                            }
                            continue;

                        case "InfoTicker":
                            if (DateTime.Now >= entry.Value)
                            {
                                infoTicker = "";
                                InfoTicker.SetDelay();
                                InfoTicker.Exec();
                            }
                            continue;

                        case "NightAlert":
                            if (DateTime.Now >= entry.Value)
                            {
                                nightAlert = "";
                                NightAlert.SetDelay();
                                NightAlert.Exec();
                            }
                            continue;

                        case "PlayerLogs":
                            if (DateTime.Now >= entry.Value)
                            {
                                playerLogs = "";
                                PlayerLogs.SetDelay();
                                PlayerLogs.Exec();
                            }
                            continue;

                        case "RealWorldTime":
                            if (DateTime.Now >= entry.Value)
                            {
                                realWorldTime = "";
                                RealWorldTime.SetDelay();
                                RealWorldTime.Exec();
                            }
                            continue;

                        case "Shutdown":
                            if (DateTime.Now >= entry.Value)
                            {
                                Remove("Shutdown");
                                Shutdown.PrepareShutdown();
                            }
                            continue;

                        case "WatchList":
                            if (DateTime.Now >= entry.Value)
                            {
                                watchList = "";
                                WatchList.SetDelay();
                                WatchList.Exec();
                            }
                            continue;

                        case "Zones":
                            if (DateTime.Now >= entry.Value)
                            {
                                zones = "";
                                Zones.SetDelay();
                                Zones.ReminderExec();
                            }
                            continue;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Out(string.Format("[SERVERTOOLS] Error in EventSchedule.Exec: {0}", e.Message));
            }
        }