Beispiel #1
0
        internal static void Init(ServerConfig.SecurityInfo info)
        {
            if (Backend != null)
            {
                return;
            }

            API.RegisterDBBackend("YAML", new Databases.YAMLFlatFileDB());
            string backend = info.BanDBBackend.ToUpperInvariant();

            lock (API.Backends)
            {
                if (API.Backends.ContainsKey(backend))
                {
                    Backend = API.Backends[backend];
                }
            }

            if (Backend != null)
            {
                Backend.Setup(info);
            }
        }
Beispiel #2
0
        public bool Setup(ServerConfig.SecurityInfo info)
        {
            if (DBWatcher != null)
            {
                DBWatcher.Dispose();
                DBWatcher = null;
            }

            DBFile = null;

            if (info.BanDBFile != string.Empty)
            {
                DBFile = new FileInfo(info.BanDBFile);
                if (DBFile.Directory.Exists && !DBFile.Exists)
                {
                    DBFile.Create().Close();
                }
            }

            LoadFile();

            if (info.BansReadOnly || !File.Exists(DBFile.FullName))
            {
                DBFile = null;
                return(true);
            }

            if (DBFile.Directory.Exists)
            {
                DBWatcher                     = new FileSystemWatcher(DBFile.Directory.FullName);
                DBWatcher.Changed            += DBWatcher_Changed;
                DBWatcher.EnableRaisingEvents = true;
            }

            return(File.Exists(DBFile.FullName));
        }
Beispiel #3
0
 public void Init(Server serverHost, ServerConfig.SecurityInfo info)
 {
     State = serverHost.State;
     serverHost.PlayerPreAdd   += ServerHost_PlayerPreAdd;
     serverHost.PlayerAccepted += ServerHost_PlayerAccepted;
 }