Beispiel #1
0
 private static Account Load(Group.List groups, string name)
 {
     try {
         string filename = "accounts/" + name + "." + host.Extension;
         string rootName;
         Node   node = host.Load(filename, out rootName);
         if (rootName != "account")
         {
             return(null);
         }
         string n = (string)node["name"].Value;
         if (n.ToLower() != name.ToLower())
         {
             return(null);
         }
         Group group = groups[(string)node["group"].Value];
         if (group == null)
         {
             return(null);
         }
         Account account    = new Account(n);
         Node    statistics = node["statistics"];
         account.group        = group;
         account.logins       = (int)statistics["logins"].Value;
         account.total        = TimeSpan.Parse((string)statistics["total"].Value);
         account.lastLogin    = DateTime.Parse((string)statistics["lastLogin"].Value);
         account.lastLogout   = DateTime.Parse((string)statistics["lastLogout"].Value);
         account.lastIP       = (string)statistics["lastIP"].Value;
         account.fileModified = File.GetLastWriteTime(filename);
         account.custom       = node["custom"] ?? account.custom;
         return(account);
     } catch { return(null); }
 }
Beispiel #2
0
            internal void Load(Group.List groups)
            {
                accounts.Clear();
                this.groups = groups;
                int loaded = 0;
                int failed = 0;
                int cursor = Console.CursorLeft;

                if (!Directory.Exists("accounts"))
                {
                    return;
                }
                foreach (string file in Directory.GetFiles("accounts", "*." + host.Extension))
                {
                    string  name    = file.Substring(9, file.Length - host.Extension.Length - 10);
                    Account account = Account.Load(groups, name);
                    if (account == null)
                    {
                        failed++;
                    }
                    else
                    {
                        loaded++; accounts.Add(account.name.ToLower(), account);
                    }
                    Console.Write(loaded + " account" + (loaded == 1?"":"s") + " loaded" + (failed == 0?"":" (" + failed + " failed)") + ".");
                    Console.CursorLeft = cursor;
                }
                Console.Write(loaded + " account" + (loaded == 1?"":"s") + " loaded" + (failed == 0?"":" (" + failed + " failed)") + ".");
            }
Beispiel #3
0
		public Server(TextWriter log) {
			this.log = log;
			
			Name = "Custom Minecraft server";
			Motd = "Welcome to my custom Minecraft server!";
			Public = false;
			Verify = true;
			Slots = 16;
			Help = "&eTo show a list of commands, type '/help commands'.";
			
			listener.AcceptEvent += Accept;
			heartbeat = new Heartbeat(this);
			updateThread = new Thread(UpdateBodies);
			lua = new Lua(this);
			Commands = new Command.List(this);
			Groups = new Group.List();
			Accounts = new Account.List();
			Queue = new UpdateQueue(this);
		}
Beispiel #4
0
 internal void Load(Group.List groups)
 {
     accounts.Clear();
     this.groups = groups;
     int loaded = 0;
     int failed = 0;
     int cursor = Console.CursorLeft;
     if (!Directory.Exists("accounts")) { return; }
     foreach (string file in Directory.GetFiles("accounts","*."+host.Extension)) {
         string name = file.Substring(9,file.Length-host.Extension.Length-10);
         Account account = Account.Load(groups,name);
         if (account==null) { failed++; }
         else { loaded++; accounts.Add(account.name.ToLower(),account); }
         Console.Write(loaded+" account"+(loaded==1?"":"s")+" loaded"+(failed==0?"":" ("+failed+" failed)")+".");
         Console.CursorLeft = cursor;
     }
     Console.Write(loaded+" account"+(loaded==1?"":"s")+" loaded"+(failed==0?"":" ("+failed+" failed)")+".");
 }