示例#1
0
        public LaunchResult Launch(LaunchOptionBase launchOption, params Action <MinecraftLaunchArguments>[] argumentsOperators)
        {
            if (UserAuthenticator == null)
            {
                FailedResult.ErrorType    = ErrorType.AuthenticationFailed;
                FailedResult.ErrorMessage = "User authenticator no set";
                Console.WriteLine("ERROR: User authenticator no set");
                return(FailedResult);
            }
            if (launchOption == null)
            {
                Console.WriteLine("ERROR: Launch message is null");
                FailedResult.ErrorMessage = "Launch message is null";
                return(FailedResult);
            }

            Core.JavaPath = launchOption.javaExt;

            //LaunchOptions in KMCCC, different with LaunchOption in OneMCL.Core
            LaunchOptions options = new LaunchOptions()
            {
                Version       = Core.GetVersion(launchOption.versionId),
                Authenticator = UserAuthenticator,
                GameDirPath   = string.IsNullOrEmpty(launchOption.gameDir) ? Core.GameRootPath : launchOption.gameDir,
            };

            Console.WriteLine("Launching...");

            int argsCount = 0;

            if (argumentsOperators != null)
            {
                argsCount = argumentsOperators.Length;
            }
            Action <MinecraftLaunchArguments>[] argsOpt = new Action <MinecraftLaunchArguments> [argsCount + 1];
            argsOpt[0] = (Action <MinecraftLaunchArguments>)(args =>
            {
                args.AdvencedArguments.Add(launchOption.javaArgs);
                System.Version osVersion = Environment.OSVersion.Version;
                args.AdvencedArguments.Add("-Dos.name=\"" + GetSystemVersionName(osVersion.Major, osVersion.Minor) + "\"");
                args.AdvencedArguments.Add("-Dos.version=" + osVersion.Major + "." + osVersion.Minor);
                args.AdvencedArguments.Add("-Dminecraft.launcher.brand=one-minecraft-launcher");
                //args.AdvencedArguments.Add("-Dminecraft.launcher.version=");
                args.AdvencedArguments.Add("-Dminecraft.client.jar=" + Core.GetVersionJarPath(options.Version));
                //args.AdvencedArguments.Add("-Dlog4j.configurationFile=");
            });
            argumentsOperators?.CopyTo(argsOpt, 1);
            return(Core.Launch(options, argsOpt));
        }