Exemplo n.º 1
0
        public void CopyVersionDirectories(string ver)
        {
            var root = SystemTools.GetIsWindows() ? string.Format(@"{0}\versions\{1}\moddir", GameRootPath, ver) : string.Format("{0}/versions/{1}/moddir", GameRootPath, ver);

            if (!Directory.Exists(root))
            {
                return;
            }
            foreach (var dir in new DirectoryInfo(root).EnumerateDirectories())
            {
                CopyDirectory(dir.FullName, (SystemTools.GetIsWindows() ? string.Format(@"{0}\{1}", GameRootPath, dir.Name) : string.Format("{0}/{1}", GameRootPath, dir.Name)));
            }
        }
Exemplo n.º 2
0
 public void CopyVersionDirectory(string directoryName, string versionId)
 {
     if (SystemTools.GetIsWindows())
     {
         CopyDirectory(string.Format(@"{0}\versions\{2}\{1}", GameRootPath, directoryName, versionId),
                       string.Format(@"{0}\{1}", GameRootPath, directoryName));
     }
     else
     {
         CopyDirectory(string.Format("{0}/versions/{2}/{1}", GameRootPath, directoryName, versionId),
                       string.Format("{0}/{1}", GameRootPath, directoryName));
     }
 }
Exemplo n.º 3
0
 public IEnumerable <Version> GetAllVersions()
 {
     try
     {
         lock (_locatingVersion)
         {
             return(new DirectoryInfo(GameRootPath + (SystemTools.GetIsWindows() ? @"\versions" : @"/versions")).EnumerateDirectories()
                    .Select(dir => GetVersionInternal(dir.Name)).Where(item => item != null));
         }
     }
     catch
     {
         return(new Version[0]);
     }
 }
Exemplo n.º 4
0
 public static string GetNativePath(this LauncherCore core, Native native)
 {
     return(String.Format(SystemTools.GetIsWindows() ? @"{0}\libraries\{1}\{2}\{3}\{2}-{3}-{4}.jar" : "{0}/libraries/{1}/{2}/{3}/{2}-{3}-{4}.jar", core.GameRootPath, native.NS.Replace(".", (SystemTools.GetIsWindows() ? @"\" : "/")), native.Name, native.Version,
                          native.NativeSuffix));
 }
Exemplo n.º 5
0
 public static string GetLibPath(this LauncherCore core, Library lib)
 {
     return(String.Format(SystemTools.GetIsWindows() ? @"{0}\libraries\{1}\{2}\{3}\{2}-{3}.jar" : "{0}/libraries/{1}/{2}/{3}/{2}-{3}.jar", core.GameRootPath, lib.NS.Replace(".", (SystemTools.GetIsWindows() ? @"\" : "/")), lib.Name, lib.Version));
 }
Exemplo n.º 6
0
 public static string GetVersionOptions(this LauncherCore core, string versionId)
 {
     return(String.Format(SystemTools.GetIsWindows() ? @"{0}\versions\{1}\options.txt" : "{0}/versions/{1}/options.txt", core.GameRootPath, versionId));
 }
Exemplo n.º 7
0
 public static string GetVersionJsonPath(this LauncherCore core, string versionId)
 {
     return(String.Format(SystemTools.GetIsWindows() ? @"{0}\versions\{1}\{1}.json" : "{0}/versions/{1}/{1}.json", core.GameRootPath, versionId));
 }
Exemplo n.º 8
0
        private LaunchResult GenerateArguments(LaunchOptions options, ref MinecraftLaunchArguments args)
        {
            try
            {
                var authentication = options.Authenticator.Do();
                if (!string.IsNullOrWhiteSpace(authentication.Error))
                {
                    return new LaunchResult
                           {
                               Success      = false,
                               ErrorType    = ErrorType.AuthenticationFailed,
                               ErrorMessage = "验证错误: " + authentication.Error
                           }
                }
                ;
                args.CGCEnabled = true;
                args.MainClass  = options.Version.MainClass;
                args.MaxMemory  = options.MaxMemory;
                args.AgentPath  = options.AgentPath;
                args.MinMemory  = options.MinMemory;
                args.NativePath = SystemTools.GetIsWindows() ? GameRootPath + @"\$natives" : GameRootPath + "/$natives";
                foreach (var native in options.Version.Natives)
                {
                    var exp = ZipTools.UnzipFile(this.GetNativePath(native), args.NativePath, native.Options);

                    if (exp == null)
                    {
                        continue;
                    }
                    return(new LaunchResult
                    {
                        Success = false,
                        ErrorType = ErrorType.UncompressingFailed,
                        ErrorMessage = string.Format("解压错误: {0}:{1}:{2}", native.NS, native.Name, native.Version),
                        Exception = exp
                    });
                }
                args.Server    = options.Server;
                args.Size      = options.Size;
                args.Libraries = options.Version.Libraries.Select(this.GetLibPath).ToList();
                args.Libraries.Add(this.GetVersionJarPath(options.Version.JarId));
                args.MinecraftArguments = options.Version.MinecraftArguments;

                string AssetsPath = options.Version.Assets == "legacy" ? (SystemTools.GetIsWindows() ? @"assets\virtual\legacy" : "assets/virtual/legacy") : "assets";
                args.Tokens.Add("auth_access_token", authentication.AccessToken.GoString());
                args.Tokens.Add("auth_session", authentication.AccessToken.GoString());
                args.Tokens.Add("auth_player_name", authentication.DisplayName);
                args.Tokens.Add("version_name", options.Version.Id);
                args.Tokens.Add("game_directory", ".");
                args.Tokens.Add("game_assets", AssetsPath);
                args.Tokens.Add("assets_root", AssetsPath);
                args.Tokens.Add("assets_index_name", options.Version.Assets);
                args.Tokens.Add("auth_uuid", authentication.UUID.GoString());
                args.Tokens.Add("user_properties", authentication.Properties);
                args.Tokens.Add("user_type", authentication.UserType);
                args.Tokens.Add("version_type", options.VersionType ?? "KMCCC Universal");

                args.AdvencedArguments = new List <string> {
                    "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true"
                };

                args.Authentication = authentication;
                args.Version        = options.Version;
                if (options.Mode != null)
                {
                    options.Mode.Operate(this, args);
                }
                return(null);
            }
            catch (Exception exp)
            {
                return(new LaunchResult {
                    Success = false, ErrorType = ErrorType.Unknown, ErrorMessage = "在生成参数时发生了意外的错误", Exception = exp
                });
            }
        }