MCSharp.Server.LoadLastSeen C# (CSharp) Method

LoadLastSeen() public static method

public static LoadLastSeen ( ) : void
return void
        public static void LoadLastSeen()
        {
            // Deserialization
            List<string> loadList = new List<string>();
            XmlSerializer xs = new XmlSerializer(typeof(List<string>));
            TextReader xr = new StreamReader("lastseen.xml");
            loadList = (List<string>) xs.Deserialize(xr);
            xr.Close();

            Dictionary<string, DateTime> dict = new Dictionary<string, DateTime>();
            foreach (string s in loadList)
            {
                string key, value;
                string[] temp = s.Split(',');
                key = temp[0];
                value = temp[1];

                dict.Add(key, DateTime.Parse(value));
            }
            Player.lastSeen = dict;
        }

Usage Example

コード例 #1
0
        public void Start()
        {
            Logger.Log("Starting Server");
            running = true;
            Logger.Log("Doing sanity checks");


            if (SanityCheck())
            {
                Logger.Log("Sanity Checks Passed");
                Properties.Load();

                if (File.Exists("lastseen.xml"))
                {
                    Server.LoadLastSeen();  //Added by bman
                }
                if (Properties.ServerAdministrator != String.Empty)
                {
                    Thread.Sleep(100);

                    SetupRanks();
                    SetupLevels();

                    if (!SetupNetwork())
                    {
                        return;
                    }

                    SetupGeneral();
                    SetupIRC();

                    // Init Heartbeat
                    MinecraftHeartbeat.Init();
                    MCSharpUpdateHeartbeat.Init();
                    WOMHeartbeat.Init();



                    // Init physics
                    physThread = new Thread(new ThreadStart(doPhysics));
                    physThread.Start();

                    // Autosaver init
                    new AutoSaver(Properties.BackupInterval);

                    // Check the port forward status
                    doPortCheck();
                }
                else
                {
                    Logger.Log("Error! No Administrator set in the server.properties", LogType.FatalError);
                }
            }
        }