示例#1
0
文件: Core.cs 项目: balu92/Fougerite
        public static void Init()
        {
            InitializeCommands();
            ShareCommand   command  = ChatCommand.GetCommand("share") as ShareCommand;
            FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand;

            if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")))
            {
                command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")))
            {
                command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml")))
            {
                Administrator.AdminList = Helper.ObjectFromXML <System.Collections.Generic.List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml"));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")))
            {
                userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp"));
            }
            else
            {
                userCache = new Dictionary <ulong, string>();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml")))
            {
                whiteList = new PList(Helper.ObjectFromXML <System.Collections.Generic.List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml")));
            }
            else
            {
                whiteList = new PList();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml")))
            {
                blackList = new PList(Helper.ObjectFromXML <System.Collections.Generic.List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml")));
            }
            else
            {
                blackList = new PList();
            }
        }
示例#2
0
文件: Core.cs 项目: balu92/Fougerite
 public static void Init()
 {
     InitializeCommands();
     ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand;
     FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand;
     if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")))
     {
         command.SetSharedDoors(Helper.ObjectFromFile<Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")));
     }
     if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")))
     {
         command2.SetFriendsLists(Helper.ObjectFromFile<Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")));
     }
     if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml")))
     {
         Administrator.AdminList = Helper.ObjectFromXML<System.Collections.Generic.List<Administrator>>(RustPPModule.GetAbsoluteFilePath("admins.xml"));
     }
     if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")))
     {
         userCache = Helper.ObjectFromFile<Dictionary<ulong, string>>(RustPPModule.GetAbsoluteFilePath("cache.rpp"));
     }
     else
     {
         userCache = new Dictionary<ulong, string>();
     }
     if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml")))
     {
         whiteList = new PList(Helper.ObjectFromXML<System.Collections.Generic.List<PList.Player>>(RustPPModule.GetAbsoluteFilePath("whitelist.xml")));
     }
     else
     {
         whiteList = new PList();
     }
     if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml")))
     {
         blackList = new PList(Helper.ObjectFromXML<System.Collections.Generic.List<PList.Player>>(RustPPModule.GetAbsoluteFilePath("bans.xml")));
     }
     else
     {
         blackList = new PList();
     }
 }
示例#3
0
        public static void Init()
        {
            InitializeCommands();
            ShareCommand   command  = ChatCommand.GetCommand("share") as ShareCommand;
            FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand;
            bool           success  = false;

            if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")))
            {
                SerializableDictionary <ulong, List <ulong> > doorsDict;
                doorsDict = Helper.ObjectFromXML <SerializableDictionary <ulong, List <ulong> > >(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"));
                Hashtable doorsSave = new Hashtable();
                foreach (KeyValuePair <ulong, List <ulong> > kvp in doorsDict)
                {
                    ArrayList arr = new ArrayList(kvp.Value);
                    doorsSave.Add(kvp.Key, arr);
                }
                command.SetSharedDoors(doorsSave);
                success = true;
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")) && !success)
            {
                command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")));
            }

            if (!File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")))
            {
                SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >();
                foreach (DictionaryEntry entry in command.GetSharedDoors())
                {
                    ulong        key   = (ulong)entry.Key;
                    ArrayList    value = (ArrayList)entry.Value;
                    List <ulong> list  = new List <ulong>(value.OfType <ulong>());
                    doorsSave.Add(key, list);
                }
                Helper.ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml"));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")))
            {
                command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml")))
            {
                Administrator.AdminList = Helper.ObjectFromXML <List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml"));
            }
            success = false;
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml")))
            {
                FileInfo fi   = new FileInfo(RustPPModule.GetAbsoluteFilePath("userCache.xml"));
                float    mega = (fi.Length / 1024f) / 1024f;
                if (mega > 0.70)
                {
                    Logger.LogWarning("Rust++ Cache.xml and Cache.rpp are getting big. Deletion is suggested.");
                }
                SerializableDictionary <ulong, string> userDict = Helper.ObjectFromXML <SerializableDictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("userCache.xml"));
                userCache = new Dictionary <ulong, string>(userDict);
                success   = true;
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")) && !success)
            {
                userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp"));
                if (!File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml")))
                {
                    Helper.ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml"));
                }
            }
            else if (!success)
            {
                userCache = new Dictionary <ulong, string>();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml")))
            {
                whiteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml")));
            }
            else
            {
                whiteList = new PList();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml")))
            {
                muteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("mutelist.xml")));
            }
            else
            {
                muteList = new PList();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml")))
            {
                blackList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml")));
            }
            else
            {
                blackList = new PList();
            }
        }
示例#4
0
        public static void Init()
        {
            InitializeCommands();
            ShareCommand   command  = ChatCommand.GetCommand("share") as ShareCommand;
            FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand;
            bool           success  = false;

            if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")))
            {
                SerializableDictionary <ulong, List <ulong> > doorsDict;
                doorsDict = Helper.ObjectFromXML <SerializableDictionary <ulong, List <ulong> > >(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"));
                Hashtable doorsSave = new Hashtable();
                foreach (KeyValuePair <ulong, List <ulong> > kvp in doorsDict)
                {
                    ArrayList arr = new ArrayList(kvp.Value);
                    doorsSave.Add(kvp.Key, arr);
                }
                command.SetSharedDoors(doorsSave);
                success = true;
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")) && !success)
            {
                command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")));
            }

            if (!File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")))
            {
                SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >();
                foreach (DictionaryEntry entry in command.GetSharedDoors())
                {
                    ulong        key   = (ulong)entry.Key;
                    ArrayList    value = (ArrayList)entry.Value;
                    List <ulong> list  = new List <ulong>(value.OfType <ulong>());
                    doorsSave.Add(key, list);
                }
                Helper.ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml"));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")))
            {
                command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")));
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml")))
            {
                Administrator.AdminList = Helper.ObjectFromXML <List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml"));
            }
            success = false;
            bool clearer = false;

            if (File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml")))
            {
                FileInfo fi   = new FileInfo(RustPPModule.GetAbsoluteFilePath("userCache.xml"));
                float    mega = (fi.Length / 1024f) / 1024f;
                if (mega > 0.65)
                {
                    try
                    {
                        //string n = Path.Combine(RustPPModule.ConfigsFolder, "userCache-OLD-" + DateTime.Now.ToShortDateString() + ".xml");
                        System.IO.File.Move(RustPPModule.GetAbsoluteFilePath("userCache.xml"),
                                            Path.Combine(RustPPModule.ConfigsFolder,
                                                         "userCache-OLD-" + DateTime.Now.ToShortDateString() + ".xml"));
                        clearer = true;
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Rust++ failed to copy the usercache file.");
                    }
                }
                else
                {
                    SerializableDictionary <ulong, string> userDict = Helper.ObjectFromXML <SerializableDictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("userCache.xml"));
                    userCache = new Dictionary <ulong, string>(userDict);
                    success   = true;
                }
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")) && !success)
            {
                if (clearer)
                {
                    File.WriteAllText(RustPPModule.GetAbsoluteFilePath("cache.rpp"), string.Empty);
                }
                userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp"));
                if (!File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml")))
                {
                    Helper.ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml"));
                }
            }
            else if (!success)
            {
                userCache = new Dictionary <ulong, string>();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml")))
            {
                whiteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml")));
            }
            else
            {
                whiteList = new PList();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml")))
            {
                muteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("mutelist.xml")));
            }
            else
            {
                muteList = new PList();
            }
            if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml")))
            {
                blackList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml")));
            }
            else
            {
                blackList = new PList();
            }
        }