Exemple #1
0
        public void Load()
        {
            try
            {
                var jsonData = File.ReadAllBytes(CONFIG_FILENAME);
                var json     = SystemUtil.RemoveUtf8BOM(jsonData);
                Entries = JsonSerializer.Deserialize <Config>(json);
            }
            catch
            {
                // Default configurations
                Entries = new Config
                {
                    JavaMaxMem     = NativeUtil.GetRecommendedMemory(),
                    WindowWidth    = 854,
                    WindowHeight   = 480,
                    AfterLaunch    = AfterLaunchBehavior.Hide,
                    DownloadSource = DownloadSource.Official,
                };
            }

            Entries.Accounts ??= new List <Account>(4);

            if (string.IsNullOrWhiteSpace(Entries.GameDir))
            {
                Entries.GameDir = Environment.CurrentDirectory + "\\.minecraft";
            }

            if (!File.Exists(Entries.JreDir + "\\javaw.exe"))
            {
                Entries.JreDir = SystemUtil.GetJavaDir();
            }

            if (Entries.JavaMaxMem == 0)
            {
                Entries.JavaMaxMem = 2048;
            }

            if (Entries.Build < 104)
            {
                Entries.Language = null; // Migrate lower version language settings
            }

            Entries.Build = AssemblyUtil.Build;
        }