- Recovery
This commit is contained in:
@@ -36,15 +36,9 @@ namespace Mitria_Minecraft_Launcher
|
||||
|
||||
#region Crate CustomDirectory
|
||||
|
||||
string customDataDirectory = CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, "config");
|
||||
if (!System.IO.Directory.Exists(customDataDirectory))
|
||||
if (!System.IO.Directory.Exists(Settings.CustomDataDirectory))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(customDataDirectory);
|
||||
}
|
||||
customDataDirectory = CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, "mods");
|
||||
if (!System.IO.Directory.Exists(customDataDirectory))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(customDataDirectory);
|
||||
System.IO.Directory.CreateDirectory(Settings.CustomDataDirectory);
|
||||
}
|
||||
|
||||
#endregion Crate CustomDirectory
|
||||
@@ -62,9 +56,61 @@ namespace Mitria_Minecraft_Launcher
|
||||
|
||||
case Updater.LauncherUpdateStatus.Same:
|
||||
Settings.LoadUserLauncherConfig();
|
||||
Settings.LoadUserClientVersion();
|
||||
bool result = DownloadServerList();
|
||||
if (result)
|
||||
{
|
||||
if (Settings.UserLauncherConfig.Profiles != null)
|
||||
{
|
||||
var newList = Settings.UserLauncherConfig.Profiles;
|
||||
|
||||
ProgramRun();
|
||||
for (int i = 0; i < Settings.UserLauncherConfig.Profiles.Count; i++)
|
||||
{
|
||||
bool existence = false;
|
||||
for (int j = 0; j < Settings.ServerInformation.Servers.Count; j++)
|
||||
{
|
||||
if (Settings.UserLauncherConfig.Profiles[i].ServerName == Settings.ServerInformation.Servers[j].ServerName)
|
||||
{
|
||||
existence = true;
|
||||
if (Settings.UserLauncherConfig.Profiles[i].OriginalArgument != Settings.ServerInformation.Servers[j].BaseArgument)
|
||||
{
|
||||
Settings.UserLauncherConfig.Profiles[i] = new LauncherConfig.Profile()
|
||||
{
|
||||
ServerName = Settings.UserLauncherConfig.Profiles[i].ServerName,
|
||||
Argument = Settings.ServerInformation.Servers[j].BaseArgument,
|
||||
OriginalArgument = Settings.ServerInformation.Servers[j].BaseArgument,
|
||||
RuntimeVersion = Settings.UserLauncherConfig.Profiles[i].RuntimeVersion,
|
||||
CustomData = Settings.UserLauncherConfig.Profiles[i].CustomData
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!existence)
|
||||
{
|
||||
newList.Remove(Settings.UserLauncherConfig.Profiles[i]);
|
||||
string path = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.UserLauncherConfig.Profiles[i].ServerName);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Directory.Delete(path, true);
|
||||
}
|
||||
path = CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, Settings.UserLauncherConfig.Profiles[i].ServerName);
|
||||
if (System.IO.Directory.Exists(path))
|
||||
{
|
||||
System.IO.Directory.Delete(path, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Settings.UserLauncherConfig.Profiles = newList;
|
||||
}
|
||||
|
||||
|
||||
ProgramRun();
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonLibrary.Log.FATAL("ServerList Get Failed");
|
||||
MessageBox.Show("ServerList get failed. \r\nPlease provide a log to the administrator and solve it.", "FATAL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -78,6 +124,18 @@ namespace Mitria_Minecraft_Launcher
|
||||
}
|
||||
}
|
||||
|
||||
private static bool DownloadServerList()
|
||||
{
|
||||
Downloader downloader = new Downloader();
|
||||
string data = downloader.DownloadString(Settings.ServerBaseUrl + Settings.ServerInformationFile);
|
||||
if (data == string.Empty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Settings.ServerInformation = CommonLibrary.XmlSystem.LoadFromData<CommonLibrary.ServerInformation>(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void ProgramRun()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
|
Reference in New Issue
Block a user