- Recovery
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Mitria_Minecraft_Launcher
|
||||
{
|
||||
@@ -9,55 +8,119 @@ namespace Mitria_Minecraft_Launcher
|
||||
#pragma warning disable S2223 // Non-constant static fields should not be visible
|
||||
public static LauncherConfig UserLauncherConfig;
|
||||
public static ClientVersion UserClientVersion;
|
||||
public static LauncherConfig.Profile NowProfile;
|
||||
|
||||
public static CommonLibrary.ServerInformation ServerInformation;
|
||||
|
||||
public static readonly string UserLauncherConfigPath = "config.xml";
|
||||
public static readonly string UserClientVersionPath = "version.xml"; // 위치 // 게임 디렉토리 +
|
||||
public static readonly string CustomDataDirectory = "CustomData";
|
||||
public static readonly string RuntimeLocation = "runtime";
|
||||
#pragma warning disable S1075 // URIs should not be hardcoded
|
||||
|
||||
public static readonly string ServerBaseUrl = "http://mitria.kr/Patchdata";
|
||||
|
||||
|
||||
#pragma warning restore S1075 // URIs should not be hardcoded
|
||||
public static readonly string ServerLauncherPatchInformationFile = "/Launcher.xml";
|
||||
public static readonly string ServerDataPatchInformationFile = "/Data.xml";
|
||||
public static readonly string BaseArgument = @"-XX:+UseG1GC -Xmx8G -Xms8G -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M";
|
||||
public static readonly string ServerLauncherPatchInformationFile = "/launcher.xml";
|
||||
public static readonly string ServerInformationFile = "/server.xml";
|
||||
public static readonly string ServerDataPatchInformationFile = "/data.xml";
|
||||
//public static readonly string BaseArgument = @"-XX:+UseG1GC -Xmx8G -Xms8G -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M";
|
||||
|
||||
public static void LoadUserLauncherConfig()
|
||||
{
|
||||
string path = System.IO.Path.GetFullPath(UserLauncherConfigPath);
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
UserLauncherConfig = CommonLibrary.XMLSystem.LoadFromPath<LauncherConfig>(path);
|
||||
UserLauncherConfig = CommonLibrary.XmlSystem.LoadFromPath<LauncherConfig>(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
UserLauncherConfig = new LauncherConfig();
|
||||
UserLauncherConfig.MinecraftPlayerName = string.Empty;
|
||||
UserLauncherConfig.Argument = Settings.BaseArgument;
|
||||
UserLauncherConfig.GameDirectory = @"C:\Games\Mitria";
|
||||
UserLauncherConfig.ShellView = false;
|
||||
UserLauncherConfig.RuntimeVersion = "0.0.0.0";
|
||||
UserLauncherConfig.CustomData = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveUserLauncherConfig()
|
||||
{
|
||||
SaveProfile();
|
||||
string path = System.IO.Path.GetFullPath(UserLauncherConfigPath);
|
||||
string pathDirectory = System.IO.Path.GetDirectoryName(path);
|
||||
if (!System.IO.Directory.Exists(pathDirectory))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(pathDirectory);
|
||||
}
|
||||
CommonLibrary.XMLSystem.Save(path, UserLauncherConfig);
|
||||
CommonLibrary.XmlSystem.Save(path, UserLauncherConfig);
|
||||
}
|
||||
|
||||
public static void ChangeProfile(string serverName)
|
||||
{
|
||||
LauncherConfig.Profile myProfile = new LauncherConfig.Profile();
|
||||
bool exists = false;
|
||||
if (Settings.UserLauncherConfig.Profiles != null)
|
||||
{
|
||||
foreach (var profile in Settings.UserLauncherConfig.Profiles)
|
||||
{
|
||||
if (profile.ServerName == serverName)
|
||||
{
|
||||
myProfile = profile;
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!exists)
|
||||
{
|
||||
foreach (var server in Settings.ServerInformation.Servers)
|
||||
{
|
||||
if (server.ServerName == serverName)
|
||||
{
|
||||
myProfile.ServerName = server.ServerName;
|
||||
myProfile.Argument = server.BaseArgument;
|
||||
myProfile.OriginalArgument = server.BaseArgument;
|
||||
myProfile.RuntimeVersion = "0.0.0.0";
|
||||
myProfile.CustomData = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
NowProfile = myProfile;
|
||||
LoadUserClientVersion();
|
||||
}
|
||||
private static void SaveProfile()
|
||||
{
|
||||
|
||||
if(NowProfile.ServerName == string.Empty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool isSave = false;
|
||||
if(Settings.UserLauncherConfig.Profiles == null)
|
||||
{
|
||||
Settings.UserLauncherConfig.Profiles = new List<LauncherConfig.Profile>();
|
||||
Settings.UserLauncherConfig.Profiles.Add(NowProfile);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < Settings.UserLauncherConfig.Profiles.Count; i++)
|
||||
{
|
||||
if (NowProfile.ServerName == Settings.UserLauncherConfig.Profiles[i].ServerName)
|
||||
{
|
||||
Settings.UserLauncherConfig.Profiles[i] = NowProfile;
|
||||
isSave = true;
|
||||
}
|
||||
}
|
||||
if(!isSave)
|
||||
{
|
||||
Settings.UserLauncherConfig.Profiles.Add(NowProfile);
|
||||
}
|
||||
|
||||
}
|
||||
public static void LoadUserClientVersion()
|
||||
{
|
||||
string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, UserClientVersionPath);
|
||||
string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, NowProfile.ServerName, UserClientVersionPath);
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
UserClientVersion = CommonLibrary.XMLSystem.LoadFromPath<ClientVersion>(path);
|
||||
UserClientVersion = CommonLibrary.XmlSystem.LoadFromPath<ClientVersion>(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,15 +135,13 @@ namespace Mitria_Minecraft_Launcher
|
||||
|
||||
public static void SaveUserClientVersion()
|
||||
{
|
||||
string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, UserClientVersionPath);
|
||||
string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, NowProfile.ServerName, UserClientVersionPath);
|
||||
string pathDirectory = System.IO.Path.GetDirectoryName(path);
|
||||
if (!System.IO.Directory.Exists(pathDirectory))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(pathDirectory);
|
||||
}
|
||||
CommonLibrary.XMLSystem.Save(path, UserClientVersion);
|
||||
CommonLibrary.XmlSystem.Save(path, UserClientVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user