public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1 to 3, found '{0}'", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { if (WatchList.IsEnabled) { WatchList.IsEnabled = false; Config.WriteXml(); Config.LoadXml(); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Watch list has been set to off")); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Watch list is already off")); return; } } else if (_params[0].ToLower().Equals("on")) { if (!WatchList.IsEnabled) { WatchList.IsEnabled = true; Config.WriteXml(); Config.LoadXml(); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Watch list has been set to on")); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Watch list is already on")); return; } } else if (_params[0].ToLower().Equals("add")) { if (_params.Count != 3) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 3, found '{0}'", _params.Count)); return; } if (_params[1].Contains("_")) { if (WatchList.Dict.ContainsKey(_params[1])) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not add '{0}'. Id is already in the watchlist", _params[1])); return; } WatchList.Dict.Add(_params[1], _params[2]); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Added Id '{0}' with the reason '{1}' to the watchlist", _params[1], _params[2])); WatchList.UpdateXml(); } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid Id '{0}'", _params[1])); return; } } else if (_params[0].ToLower().Equals("remove")) { if (_params.Count != 2) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 2, found '{0}'", _params.Count)); return; } if (_params[1].Contains("_")) { if (!WatchList.Dict.ContainsKey(_params[1])) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id '{0}' was not found on the list", _params[1])); return; } WatchList.Dict.Remove(_params[1]); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed Id '{0}' from the watchlist", _params[1])); WatchList.UpdateXml(); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid Id '{0}'", _params[1])); return; } } else if (_params[0].ToLower().Equals("list")) { if (_params.Count != 1) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found '{0}'", _params.Count)); return; } if (WatchList.Dict.Count < 1) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output("[SERVERTOOLS] There are no Id on the watchlist"); return; } foreach (KeyValuePair <string, string> _key in WatchList.Dict) { string _output = string.Format("{0} {1}", _key.Key, _key.Value); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(_output); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid argument '{0}'", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in WatchlistConsole.Execute: {0}", e.Message)); } }
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)); } }