Exemple #1
0
        public static void Load()
        {
            if (!File.Exists("SSC/config.json"))
            {
                ServerSideCharacter2.Config = ConfigData.DefaultConfig();
            }
            else
            {
                try
                {
                    string data;
                    using (var reader = new StreamReader(defaultName, Encoding.UTF8))
                    {
                        data = reader.ReadToEnd();
                    }

                    ServerSideCharacter2.Config = JsonConvert.DeserializeObject <ConfigData>(data);
                    QQAuth.ConnectionStr        = $"server={ServerSideCharacter2.Config.ServerAddr};User Id={ServerSideCharacter2.Config.ServerUserID};Password={ServerSideCharacter2.Config.ServerPassword};" +
                                                  $"Database={ServerSideCharacter2.Config.DatabaseName};port={ServerSideCharacter2.Config.ServerPort}";
                }
                catch (Exception ex)
                {
                    CommandBoardcast.ConsoleError("读取配置文件出错,重置为默认配置");
                    CommandBoardcast.ConsoleError(ex);
                    ServerSideCharacter2.Config = ConfigData.DefaultConfig();
                }
            }
            CommandBoardcast.ConsoleMessage("配置文件已经加载");
            CommandBoardcast.ConsoleMessage(
                $"当前配置  自动保存: {(ServerSideCharacter2.Config.AutoSave ? "开" : "关")},自动保存间隔:{ServerSideCharacter2.Config.SaveInterval / 60f}s");

            GroupConfigManager            = new GroupConfig();
            UnionDataManager              = new Unions.UnionConfig();
            RegionConfig                  = new RegionConfig();
            ServerSideCharacter2.RankData = RankData.Load();

            Save();
        }
 protected override void LoadDefaultConfig()
 {
     PrintWarning("Creating a new configuration file");
     configData = ConfigData.DefaultConfig();
 }
 protected override void LoadDefaultConfig()
 {
     PrintWarning(Lang("NoConfig"));
     _config = ConfigData.DefaultConfig();
 }