Exemplo n.º 1
0
 public static void Load()
 {
     if (!RunTimePatch.Applied)
     {
         RunTimePatch.PatchAll();
     }
     if (!Timers.IsRunning)
     {
         Timers.TimerStart();
     }
     if (!LoadTriggers.IsRunning)
     {
         LoadTriggers.Load();
     }
     if (Poll.IsEnabled && PersistentContainer.Instance.PollOpen)
     {
         Poll.CheckTime();
     }
     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 (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 (InvalidItems.IsRunning && !InvalidItems.IsEnabled)
     {
         InvalidItems.Unload();
     }
     if (!InvalidItems.IsRunning && InvalidItems.IsEnabled)
     {
         InvalidItems.Load();
     }
     if (HighPingKicker.IsRunning && !HighPingKicker.IsEnabled)
     {
         HighPingKicker.Unload();
     }
     if (!HighPingKicker.IsRunning && 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 (KillNotice.IsRunning && !KillNotice.IsEnabled)
     {
         KillNotice.Unload();
     }
     if (!KillNotice.IsRunning && KillNotice.IsEnabled)
     {
         KillNotice.Load();
     }
     if (Prayer.IsRunning && !Prayer.IsEnabled)
     {
         Prayer.Unload();
     }
     if (!Prayer.IsRunning && Prayer.IsEnabled)
     {
         Prayer.Load();
     }
     if (BloodmoonWarrior.IsRunning && !BloodmoonWarrior.IsEnabled)
     {
         BloodmoonWarrior.Unload();
     }
     if (!BloodmoonWarrior.IsRunning && BloodmoonWarrior.IsEnabled)
     {
         BloodmoonWarrior.Load();
     }
     if (ProtectedSpaces.IsRunning && !ProtectedSpaces.IsEnabled)
     {
         ProtectedSpaces.Unload();
     }
     if (!ProtectedSpaces.IsRunning && ProtectedSpaces.IsEnabled)
     {
         ProtectedSpaces.Load();
     }
     if (ClanManager.IsEnabled)
     {
         ClanManager.ClanList();
     }
     if (Auction.IsEnabled)
     {
         Auction.AuctionList();
     }
     if (Mute.IsEnabled)
     {
         Mute.ClientMuteList();
         Mute.MuteList();
     }
     if (Jail.IsEnabled)
     {
         Jail.JailList();
     }
     //always load the website last
     if (WebsiteServer.IsEnabled && !WebsiteServer.DirFound)
     {
         WebsiteServer.CheckDir();
     }
     if (WebsiteServer.IsRunning && !WebsiteServer.IsEnabled)
     {
         WebsiteServer.Unload();
     }
     if (!WebsiteServer.IsRunning && WebsiteServer.IsEnabled && WebsiteServer.DirFound)
     {
         WebsiteServer.Load();
     }
 }
Exemplo n.º 2
0
        public static void Load()
        {
            if (!Directory.Exists(API.ConfigPath))
            {
                Directory.CreateDirectory(API.ConfigPath);
                Log.Out(string.Format("[SERVERTOOLS] Created new directory '{0}'", API.ConfigPath));
            }
            else
            {
                Log.Out(string.Format("[SERVERTOOLS] Located 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");
            }
            if (!Directory.Exists(API.GamePath + "/Mods/ServerTools/Config"))
            {
                Directory.CreateDirectory(API.GamePath + "/Mods/ServerTools/Config");
            }
            if (!Directory.Exists(API.GamePath + "/Mods/ServerTools/Config/XUi"))
            {
                Directory.CreateDirectory(API.GamePath + "/Mods/ServerTools/Config/XUi");
            }

            StateManager.Awake();

            RunTimePatch.PatchAll();

            Config.Load();
            Log.Out("[SERVERTOOLS] Running ServerTools v.{0}", Config.Version);

            CommandList.BuildList();
            CommandList.Load();

            PersistentOperations.SetFolders();
            PersistentOperations.CreateCustomXUi();
            PersistentOperations.GetCurrencyName();
            PersistentOperations.EntityIdList();
            PersistentOperations.Player_Killing_Mode = GamePrefs.GetInt(EnumGamePrefs.PlayerKillingMode);

            Mods.Load();

            Phrases.Load();

            HowToSetup.Load();

            if (Fps.IsEnabled)
            {
                Fps.SetTarget();
            }

            if (SleeperRespawn.IsEnabled)
            {
                try
                {
                    SingletonMonoBehaviour <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] Xml log clean up complete"));
            }
            catch (XmlException e)
            {
                Log.Out("[SERVERTOOLS] Failed to delete old logs. Error = {0}", e.Message);
            }

            if (PersistentContainer.Instance.WorldSeed == 0)
            {
                PersistentContainer.Instance.WorldSeed = GameManager.Instance.World.Seed;
                PersistentContainer.DataChange         = true;
            }
            else if (PersistentContainer.Instance.WorldSeed != GameManager.Instance.World.Seed)
            {
                PersistentContainer.Instance.WorldSeed = GameManager.Instance.World.Seed;
                PersistentContainer.DataChange         = true;
                if (!CleanBin.IsEnabled && PersistentContainer.Instance.Players.IDs.Count > 0)
                {
                    Log.Out("[SERVERTOOLS] Detected a new world. You have old ServerTools data saved from the last map. Run the Clean_Bin tool to remove the data of your choice");
                }
            }

            if (PersistentContainer.Instance.Connections == null)
            {
                Dictionary <string, byte[]> connections = new Dictionary <string, byte[]>();
                PersistentContainer.Instance.Connections = connections;
                Dictionary <string, DateTime> timeOuts = new Dictionary <string, DateTime>();
                PersistentContainer.Instance.ConnectionTimeOut = timeOuts;
                PersistentContainer.DataChange = true;
            }

            if (CleanBin.IsEnabled)
            {
                CleanBin.Exec();
                Log.Out("[SERVERTOOLS] ServerTools.bin has been cleaned. The tool will now disable automatically");
                CleanBin.IsEnabled = false;
                Config.WriteXml();
                Config.LoadXml();
            }

            Track.Cleanup();

            DroppedBagProtection.BuildList();
            BlackJack.BuildDeck();

            ActiveTools.Exec(true);

            Timers.Thirty_Second_Delay();
            Timers.PersistentDataSave();
        }