private static void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)//Setting player view and profile { try { if (_cInfo != null) { if (CredentialCheck.IsEnabled && !CredentialCheck.AccCheck(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for false credentials. Contact an admin if this is a mistake\"", _cInfo.playerId), (ClientInfo)null); return; } if (CountryBan.IsEnabled && CountryBan.IsCountryBanned(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned your country or region code\"", _cInfo.playerId), (ClientInfo)null); return; } PersistentContainer.Instance.Players[_cInfo.playerId].LastJoined = DateTime.Now; PersistentContainer.Instance.Save(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawning: {0}.", e.Message)); } }
public static void Load() { try { Log.Out(string.Format("[SERVERTOOLS] Checking for save directory {0}", API.ConfigPath)); if (!Directory.Exists(API.ConfigPath)) { Directory.CreateDirectory(API.ConfigPath); Log.Out(string.Format("[SERVERTOOLS] Created directory {0}", API.ConfigPath)); } if (!Directory.Exists(API.ConfigPath + "/Logs/ChatLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ChatLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DetectionLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DetectionLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BountyLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BountyLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/AuctionLog")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/AuctionLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BankLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BankLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DupeLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DupeLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PlayerLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PlayerLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PlayerReports")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PlayerReports"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PollLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PollLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/ChatCommandLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ChatCommandLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DamageLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DamageLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BlockLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BlockLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/ConsoleCommandLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ConsoleCommandLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/WebsiteLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/WebsiteLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/OutputLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/OutputLogs"); } } catch (XmlException e) { Log.Out(string.Format("[SERVERTOOLS] Error in creation of directory {0}. Error = {1}", API.ConfigPath, e.Message)); } try { StateManager.Awake(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the persistent database bin file. Restart the server and check for errors. Error = {0}", e.Message); } try { Config.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the configuration file. Error = {0}", e.Message); } try { Mods.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the tools. Restart the server and check for errors. Error = {0}", e.Message); } try { Triggers.LoadXml(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the EventTriggers.xml. Check for errors in the file. Error = {0}", e.Message); } try { Phrases.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the Phrases.xml. Restart the server and check for errors. Error = {0}", e.Message); } try { HowToSetup.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the HowToSetup.xml. Error = {0}", e.Message); } if (Fps.IsEnabled) { try { Fps.SetTarget(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to set the target fps. Error = {0}", e.Message); } } if (SleeperRespawn.IsEnabled) { try { SdtdConsole.Instance.ExecuteSync(string.Format("sleeperreset"), null); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to reset sleeper spawn points. Error = {0}", e.Message); } } try { Log.Out(string.Format("[SERVERTOOLS] Deleting old logs")); int _daysBeforeDeleted = Days_Before_Log_Delete * -1; string[] files = Directory.GetFiles(API.ConfigPath + "/Logs/DetectionLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/BountyLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/AuctionLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/BankLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/DupeLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/PlayerLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/PlayerReports"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/PollLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/ChatLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/ChatCommandLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/DamageLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/BlockLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/ConsoleCommandLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/WebsiteLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/OutputLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } Log.Out(string.Format("[SERVERTOOLS] Log clean up completed")); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to delete old logs. Error = {0}", e.Message); } PersistentOperations.EntityIdList(); RestartVote.Cycle = true; Track.Cleanup(); CountryBan.FileCheck(); Timers.LogAlert(); Timers.LoadAlert(); }
public void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { if (_cInfo != null) { if (CountryBan.IsEnabled && _cInfo.ip != "127.0.0.1" && !_cInfo.ip.StartsWith("192.168")) { if (CountryBan.IsCountryBanned(_cInfo)) { return; } } string _sql = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId);; DataTable _result = SQL.TQuery(_sql); string _name = SQL.EscapeString(_cInfo.playerName); if (_result.Rows.Count == 0) { _sql = string.Format("INSERT INTO Players (steamid, playername, last_joined) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _name, DateTime.Now); } else { _sql = string.Format("UPDATE Players SET playername = '{0}', last_joined = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _cInfo.playerId); } _result.Dispose(); SQL.FastQuery(_sql); if (StopServer.NoEntry) { int _seconds = (60 - Timers._sSCD); string _phrase452; if (!Phrases.Dict.TryGetValue(452, out _phrase452)) { _phrase452 = "Shutdown is in {Minutes} minutes {Seconds} seconds. Please come back after the server restarts."; } _phrase452 = _phrase452.Replace("{Minutes}", Timers._sSC.ToString()); _phrase452 = _phrase452.Replace("{Seconds}", _seconds.ToString()); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase452), (ClientInfo)null); } if (ReservedSlots.IsEnabled) { if (ReservedSlots.Kicked.ContainsKey(_cInfo.playerName)) { DateTime _dateTime; ReservedSlots.Kicked.TryGetValue(_cInfo.playerId, out _dateTime); TimeSpan varTime = DateTime.Now - _dateTime; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (_timepassed >= 5) { int _timeleft = 5 - _timepassed; string _phrase22; if (!Phrases.Dict.TryGetValue(22, out _phrase22)) { _phrase22 = "Sorry {PlayerName} you have reached the max session time. Please wait {TimeRemaining} minutes before rejoining."; } _phrase22 = _phrase22.Replace("{PlayerName}", _cInfo.playerName); _phrase22 = _phrase22.Replace("{TimeRemaining}", _timeleft.ToString()); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase22), (ClientInfo)null); } else { ReservedSlots.CheckReservedSlot(_cInfo); } } else { ReservedSlots.CheckReservedSlot(_cInfo); } } if (CredentialCheck.IsEnabled) { CredentialCheck.AccCheck(_cInfo); } if (Motd.IsEnabled && !Motd.Show_On_Respawn) { Motd.Send(_cInfo); } if (AutoShutdown.IsEnabled) { if (AutoShutdown.Alert_On_Login) { AutoShutdown.CheckNextShutdown(_cInfo, false); } } if (Bloodmoon.Show_On_Login && !Bloodmoon.Show_On_Respawn) { Bloodmoon.GetBloodmoon(_cInfo, false); } if (LoginNotice.IsEnabled) { LoginNotice.PlayerCheck(_cInfo); } Players.SessionTime(_cInfo); } }
private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player { try { if (_cInfo != null && _cInfo.playerId.Length == 17) { if (CredentialCheck.IsEnabled && !CredentialCheck.AccCheck(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for false credentials. Contact an admin if this is a mistake\"", _cInfo.playerId), null); return; } if (CountryBan.IsEnabled && CountryBan.IsCountryBanned(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for country IP region\"", _cInfo.playerId), null); return; } PersistentContainer.Instance.Players[_cInfo.playerId].LastJoined = DateTime.Now; if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawning. Game bug has returning players trigger this on server restarts { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentOperations.SessionTime(_cInfo); if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer) { Timers.NewPlayerExecTimer(_cInfo); } else { OldPlayerJoined(_cInfo); } } else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawning { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentOperations.SessionTime(_cInfo); if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer) { Timers.NewPlayerExecTimer(_cInfo); } else { OldPlayerJoined(_cInfo); } } else if (_respawnReason == RespawnType.Died)//Player died, respawning { PersistentOperations.SessionTime(_cInfo); PlayerDied(_cInfo); } else if (_respawnReason == RespawnType.Teleport) { if (Teleportation.Teleporting.Contains(_cInfo.entityId)) { Teleportation.Teleporting.Remove(_cInfo.entityId); } } if (BattleLogger.IsEnabled && !BattleLogger.Exit.Contains(_cInfo.playerId) && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > BattleLogger.Admin_Level) { BattleLogger.Exit.Add(_cInfo.playerId); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}", e.Message)); } }
private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player { try { if (_cInfo != null && _cInfo.playerId != null) { if (CredentialCheck.IsEnabled && !CredentialCheck.AccCheck(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for false credentials. Contact an admin if this is a mistake\"", _cInfo.playerId), null); return; } if (CountryBan.IsEnabled && CountryBan.IsCountryBanned(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for country IP region\"", _cInfo.playerId), null); return; } PersistentContainer.Instance.Players[_cInfo.playerId].LastJoined = DateTime.Now; if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentOperations.SessionTime(_cInfo); if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawning. Game bug can trigger this incorrectly { if (_player.distanceWalked < 1 && _player.totalTimePlayed <= 1) { Timers.NewPlayerTimer(_cInfo); } else { OldPlayerJoined(_cInfo, _player); } } else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawning { if (_player.distanceWalked < 1 && _player.totalTimePlayed <= 10) { Timers.NewPlayerTimer(_cInfo); } else { OldPlayerJoined(_cInfo, _player); } } else if (_respawnReason == RespawnType.Died)//Player died, respawning { PlayerDied(_cInfo); } else if (_respawnReason == RespawnType.Teleport) { if (Teleportation.Teleporting.Contains(_cInfo.entityId)) { Teleportation.Teleporting.Remove(_cInfo.entityId); } } } if (ExitCommand.IsEnabled && !ExitCommand.Players.ContainsKey(_cInfo.entityId) && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > ExitCommand.Admin_Level) { ExitCommand.Players.Add(_cInfo.entityId, _player.position); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}", e.Message)); } }
public static void Load() { Timers.TimerStart(); if (TeleportCheck.IsEnabled) { TeleportCheck.DetectionLogsDir(); } if (CountryBan.IsEnabled) { CountryBan.Load(); } if (FlightCheck.IsEnabled) { FlightCheck.DetectionLogsDir(); } if (HatchElevator.IsEnabled) { HatchElevator.DetectionLogsDir(); } if (PlayerLogs.IsEnabled) { PlayerLogs.PlayerLogsDir(); } if (InventoryCheck.IsEnabled) { InventoryCheck.PlayerLogsDir(); } if (Report.IsEnabled) { Report.ReportLogsDir(); } if (PlayerStatCheck.IsEnabled) { PlayerStatCheck.DetectionLogsDir(); } if (UndergroundCheck.IsEnabled) { UndergroundCheck.DetectionLogsDir(); } if (Zones.IsEnabled) { Zones.DetectionLogsDir(); } if (Bank.IsEnabled) { Bank.CreateFolder(); } if (AuctionBox.IsEnabled) { AuctionBox.CreateFolder(); } if (Bounties.IsEnabled) { Bounties.CreateFolder(); } if (CredentialCheck.IsEnabled) { CredentialCheck.CreateFolder(); } if (DupeLog.IsEnabled) { DupeLog.CreateFolder(); } PollConsole.CreateFolder(); string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'"; DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { PollConsole.Check(); } _result.Dispose(); if (ClanManager.IsEnabled) { ClanManager.GetClans(); ClanManager.BuildList(); } if (!ClanManager.IsEnabled) { ClanManager.clans.Clear(); ClanManager.ClanMember.Clear(); } if (!InfoTicker.IsEnabled && InfoTicker.IsRunning) { InfoTicker.Unload(); } if (InfoTicker.IsEnabled && !InfoTicker.IsRunning) { InfoTicker.Load(); } if (Gimme.IsRunning && !Gimme.IsEnabled) { Gimme.Unload(); } if (!Gimme.IsRunning && Gimme.IsEnabled) { Gimme.Load(); } if (UndergroundCheck.IsRunning && !UndergroundCheck.IsEnabled) { UndergroundCheck.Unload(); } if (!UndergroundCheck.IsRunning && UndergroundCheck.IsEnabled) { UndergroundCheck.Load(); } if (Badwords.IsRunning && !Badwords.IsEnabled) { Badwords.Unload(); } if (!Badwords.IsRunning && Badwords.IsEnabled) { Badwords.Load(); } if (!LoginNotice.IsRunning && LoginNotice.IsEnabled) { LoginNotice.Load(); } if (LoginNotice.IsRunning && !LoginNotice.IsEnabled) { LoginNotice.Unload(); } if (!Zones.IsRunning && Zones.IsEnabled) { Zones.Load(); } if (Zones.IsRunning && !Zones.IsEnabled) { Zones.Unload(); } if (!VoteReward.IsRunning && VoteReward.IsEnabled) { VoteReward.Load(); } if (VoteReward.IsRunning && !VoteReward.IsEnabled) { VoteReward.Unload(); } if (!Watchlist.IsRunning && Watchlist.IsEnabled) { Watchlist.Load(); } if (Watchlist.IsRunning && !Watchlist.IsEnabled) { Watchlist.Unload(); } if (!ReservedSlots.IsRunning && ReservedSlots.IsEnabled) { ReservedSlots.Load(); } if (ReservedSlots.IsRunning && !ReservedSlots.IsEnabled) { ReservedSlots.Unload(); } if (!StartingItems.IsRunning && StartingItems.IsEnabled) { StartingItems.Load(); } if (StartingItems.IsRunning && !StartingItems.IsEnabled) { StartingItems.Unload(); } if (!Travel.IsRunning && Travel.IsEnabled) { Travel.Load(); } if (Travel.IsRunning && !Travel.IsEnabled) { Travel.Unload(); } if (!Shop.IsRunning && Shop.IsEnabled) { Shop.Load(); } if (Shop.IsRunning && !Shop.IsEnabled) { Shop.Unload(); } if (!Motd.IsRunning && Motd.IsEnabled) { Motd.Load(); } if (Motd.IsRunning && !Motd.IsEnabled) { Motd.Unload(); } if (InventoryCheck.IsRunning && !InventoryCheck.IsEnabled) { InventoryCheck.Unload(); } if (!InventoryCheck.IsRunning && InventoryCheck.IsEnabled) { InventoryCheck.Load(); } if (HighPingKicker.IsEnabled) { HighPingKicker.Load(); } if (CredentialCheck.IsRunning && !CredentialCheck.IsEnabled) { CredentialCheck.Unload(); } if (!CredentialCheck.IsRunning && CredentialCheck.IsEnabled) { CredentialCheck.Load(); } if (CustomCommands.IsRunning && !CustomCommands.IsEnabled) { CustomCommands.Unload(); } if (!CustomCommands.IsRunning && CustomCommands.IsEnabled) { CustomCommands.Load(); } if (DupeLog.IsRunning && !DupeLog.IsEnabled) { DupeLog.Unload(); } if (!DupeLog.IsRunning && DupeLog.IsEnabled) { DupeLog.Load(); } if (ChatColorPrefix.IsRunning && !ChatColorPrefix.IsEnabled) { ChatColorPrefix.Unload(); } if (!ChatColorPrefix.IsRunning && ChatColorPrefix.IsEnabled) { ChatColorPrefix.Load(); } if (MutePlayer.IsEnabled) { MutePlayer.MuteList(); } if (Jail.IsEnabled) { Jail.JailList(); } if (Animals.IsEnabled) { Animals.AnimalList(); } if (AutoShutdown.IsEnabled) { AutoShutdown.ShutdownTime(); } }
public static void Load(int _state) { if (_state == 1) { try { Log.Out(string.Format("[SERVERTOOLS] Checking for save directory {0}", API.ConfigPath)); if (!Directory.Exists(API.ConfigPath)) { Directory.CreateDirectory(API.ConfigPath); Log.Out(string.Format("[SERVERTOOLS] Created directory {0}", API.ConfigPath)); } if (!Directory.Exists(API.ConfigPath + "/Logs/ChatLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ChatLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DetectionLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DetectionLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BountyLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BountyLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/AuctionLog")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/AuctionLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BankLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BankLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DupeLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DupeLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PlayerLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PlayerLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PlayerReports")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PlayerReports"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PollLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PollLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/ChatCommandLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ChatCommandLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DamageLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DamageLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BlockLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BlockLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/ConsoleCommandLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ConsoleCommandLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/WebsiteLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/WebsiteLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/OutputLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/OutputLogs"); } } catch (XmlException e) { Log.Out(string.Format("[SERVERTOOLS] Error in creation of directory {0}. Error = {1}", API.ConfigPath, e.Message)); } Load(2); } else if (_state == 2) { try { StateManager.Awake(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the persistent database bin file. Restart the server and check for errors. Error = {0}", e.Message); } Load(3); } else if (_state == 3) { try { LoadConfig.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the configuration file. Error = {0}", e.Message); } Load(4); } else if (_state == 4) { try { Mods.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the tools. Restart the server and check for errors. Error = {0}", e.Message); } Load(5); } else if (_state == 5) { try { LoadTriggers.LoadXml(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the EventTriggers.xml. Check for errors in the file. Error = {0}", e.Message); } Load(6); } else if (_state == 6) { try { Phrases.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the Phrases.xml. Restart the server and check for errors. Error = {0}", e.Message); } try { HowToSetup.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the HowToSetup.xml. Error = {0}", e.Message); } Load(7); } else if (_state == 7) { if (Fps.IsEnabled) { try { Fps.SetTarget(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to set the target fps. Error = {0}", e.Message); } } Load(8); } else if (_state == 8) { Log.Out(string.Format("[SERVERTOOLS] Deleting old logs")); int _daysBeforeDeleted = Days_Before_Log_Delete * -1; string[] files = Directory.GetFiles(API.ConfigPath + "/Logs/DetectionLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/BountyLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/AuctionLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/BankLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/DupeLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/PlayerLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/PlayerReports"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/PollLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/ChatLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/ChatCommandLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/DamageLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/BlockLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/ConsoleCommandLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/WebsiteLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } files = Directory.GetFiles(API.ConfigPath + "/Logs/OutputLogs"); if (files != null && files.Length > 0) { foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.CreationTime < DateTime.Now.AddDays(_daysBeforeDeleted)) { fi.Delete(); } } } Log.Out(string.Format("[SERVERTOOLS] Log clean up completed")); Load(9); } else if (_state == 9) { RestartVote.Startup = true; Load(10); } else if (_state == 10) { Track.Cleanup(); Load(11); } else if (_state == 11) { CountryBan.FileCheck(); Load(12); } else if (_state == 12) { Timers.LogAlert(); Timers.LoadAlert(); } }
public static void Load() { try { Log.Out(string.Format("[SERVERTOOLS] Checking for save directory {0}", API.ConfigPath)); if (!Directory.Exists(API.ConfigPath)) { Directory.CreateDirectory(API.ConfigPath); Log.Out(string.Format("[SERVERTOOLS] Created directory {0}", API.ConfigPath)); } if (!Directory.Exists(API.ConfigPath + "/Logs/ChatLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ChatLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DetectionLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DetectionLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BountyLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BountyLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/AuctionLog")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/AuctionLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BankLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BankLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DupeLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DupeLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PlayerLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PlayerLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PlayerReports")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PlayerReports"); } if (!Directory.Exists(API.ConfigPath + "/Logs/PollLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/PollLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/ChatCommandLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ChatCommandLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/DamageLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/DamageLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/BlockLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/BlockLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/ConsoleCommandLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/ConsoleCommandLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/WebPanelLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/WebPanelLogs"); } if (!Directory.Exists(API.ConfigPath + "/Logs/OutputLogs")) { Directory.CreateDirectory(API.ConfigPath + "/Logs/OutputLogs"); } } catch (XmlException e) { Log.Out(string.Format("[SERVERTOOLS] Error in creation of directory @ {0}. Error = {1}", API.ConfigPath, e.Message)); } try { StateManager.Awake(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the persistent database bin file. Restart the server and check for errors. Error = {0}", e.Message); } try { Config.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the configuration file. Error = {0}", e.Message); } try { Mods.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the tools. Restart the server and check for errors. Error = {0}", e.Message); } try { Triggers.LoadXml(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the EventTriggers.xml. Check for errors in the file. Error = {0}", e.Message); } try { Phrases.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the Phrases.xml. Restart the server and check for errors. Error = {0}", e.Message); } try { HowToSetup.Load(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to load the HowToSetup.xml. Error = {0}", e.Message); } if (Fps.IsEnabled) { try { Fps.SetTarget(); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to set the target fps. Error = {0}", e.Message); } } if (SleeperRespawn.IsEnabled) { try { SdtdConsole.Instance.ExecuteSync(string.Format("sleeperreset"), null); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to reset sleeper spawn points. Error = {0}", e.Message); } } try { DeleteFiles("DetectionLogs"); DeleteFiles("BountyLogs"); DeleteFiles("AuctionLogs"); DeleteFiles("BankLogs"); DeleteFiles("DupeLogs"); DeleteFiles("PlayerLogs"); DeleteFiles("PlayerReports"); DeleteFiles("PollLogs"); DeleteFiles("ChatLogs"); DeleteFiles("ChatCommandLogs"); DeleteFiles("DamageLogs"); DeleteFiles("BlockLogs"); DeleteFiles("ConsoleCommandLogs"); DeleteFiles("WebPanelLogs"); DeleteFiles("OutputLogs"); Log.Out(string.Format("[SERVERTOOLS] Log clean up completed")); } catch (XmlException e) { Log.Out("[SERVERTOOLS] Failed to delete old logs. Error = {0}", e.Message); } PersistentOperations.EntityIdList(); CountryBan.BuildList(); RestartVote.Cycle = true; Track.Cleanup(); Timers.LogAlert(); Timers.LoadAlert(); Timers.PersistentDataSave(); }