private async void Border_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (tit.Text == "")
     {
         LauncherCore dt;
         if (paths != "sss")
         {
             dt = LauncherCore.Create(paths);
         }
         else
         {
             dt = LauncherCore.Create();
         }
         dt.JavaPath = AppDomain.CurrentDomain.BaseDirectory + @"jre8\bin\javaw.exe";;
         var ver    = dt.GetVersions().ToArray()[0];
         var result = dt.Launch(new LaunchOptions
         {
             Version       = ver,
             MaxMemory     = 514,
             Authenticator = new OfflineAuthenticator(UserName.Text),
         });
         Settings.Default.UserName = UserName.Text;
         Settings.Default.Save();
         var d = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(0.2));
         d.Completed += delegate { Environment.Exit(0); };
         this.BeginAnimation(OpacityProperty, d);
     }
     else
     {
         tit.Text = "游戏数据尚未加载或加载失败,无法启动游戏"; await Task.Delay(2000); tit.Text = "";
     }
 }
        public static void VLW(string username, string password, string memory, string path, bool fullScreen)
        {
            string serverStr = "28f8f58a8a7f11e88feb525400b59b6a";
            // var versions = Program.Core.GetVersions().ToArray();
            var core   = LauncherCore.Create();
            var ver    = core.GetVersion("1.13");
            var option = new LaunchOptions
            {
                Version   = ver,                     //Ver为Versions里你要启动的版本名字
                MaxMemory = Convert.ToInt32(memory), //最大内存,int类型
                AgentPath = @"nide8auth.jar=" + serverStr,
                // Authenticator = new OfflineAuthenticator(username), //离线启动,设置的游戏名
                Authenticator = new YggdrasilLogin(username, password, true, null, "https://auth2.nide8.com:233/" + serverStr + "/authserver"), // 伪正版启动,最后一个为是否twitch登录
                Mode          = LaunchMode.MCLauncher,                                                                                          //启动模式
                // Server = new ServerInfo { Address = "ali.cge.hm", Port = 30033 }, //设置启动游戏后,自动加入指定IP的服务器,可以不要

                /*
                 * Size = new WindowSize
                 * {
                 *  Height = 720,
                 *  Width = 1280,
                 * } //设置窗口大小,可以不要
                 */
            };

            if (fullScreen)
            {
                option.Size.FullScreen = true;
            }
            var result = Program.Core.Launch(option);

            if (!result.Success)
            {
                switch (result.ErrorType)
                {
                case ErrorType.NoJAVA:
                    MessageBox.Show("Java Error, try to reinstall the client.", "Java Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case ErrorType.AuthenticationFailed:
                    MessageBox.Show("Please check your username and password.", "Check Profile", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    break;

                case ErrorType.UncompressingFailed:
                    MessageBox.Show("Depressing Failed!\nCheck your client or reinstall.", "Uncompressing Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                default:
                    MessageBox.Show(
                        result.ErrorMessage + "\n" +
                        (result.Exception == null ? string.Empty : result.Exception.StackTrace),
                        "Error Occured: Unknown");
                    break;
                }
            }
            Thread.Sleep(50);
        }
 public MainWindow()
 {
     InitializeComponent();
     UserName.Text = Settings.Default.UserName;
     Reporter.SetClientName("Lc-1.7.2");
     try {
         if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + ".minecraft") && Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + ".jre"))
         {
             Asd.Text = "Minecraft  " + LauncherCore.Create().GetVersions().ToArray()[0].Assets;
         }
     }catch { Asd.Text = "没有检测到MC,点我添加"; }
 }
示例#4
0
        private void StartGameBtn_Click(object sender, EventArgs e)
        {
            if (UsernameTxt.Text == "" || MaxMemoryTxt.Text == "" || JavaPathTxt.Text == "")
            {
                MessageBox.Show(this, "请填写完整的设置", "错误提示");
                return;
            }

            PgLog.print("GameStart");

            var core = LauncherCore.Create();
            //MessageBox.Show(core.GameRootPath);
            var Launchversion = core.GetVersion(App.LaunchVer);

            core.JavaPath = JavaPathTxt.Text;
            ushort X, Y;

            if (GameSizeXTxt.Text != "" && GameSizeYTxt.Text != "")
            {
                X = ushort.Parse(GameSizeXTxt.Text);
                Y = ushort.Parse(GameSizeYTxt.Text);
            }
            else
            {
                X = 1100;
                Y = 510;
            }
            var result = core.Launch(new LaunchOptions
            {
                Version       = Launchversion,                              //Ver为Versions里你要启动的版本名字
                MaxMemory     = int.Parse(MaxMemoryTxt.Text),               //最大内存,int类型
                Authenticator = new OfflineAuthenticator(UsernameTxt.Text), //离线启动,ZhaiSoul那儿为你要设置的游戏名
                //Authenticator = new YggdrasilLogin("邮箱", "密码", true), // 正版启动,最后一个为是否twitch登录
                //启动模式,这个我会在后面解释有哪几种
                //Server = new ServerInfo { Address = "服务器IP地址", Port = "服务器端口" },

                Size = new WindowSize {
                    Height = Y, Width = X
                }                                              //设置窗口大小,可以不要
            });

            if (result.Success)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show(result.ErrorMessage);
            }
        }
示例#5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var core          = LauncherCore.Create();
            var Launchversion = core.GetVersion("1.13.2");
            var result        = App.launcherCore.Launch(new LaunchOptions
            {
                Version       = Launchversion,                         //Ver为Versions里你要启动的版本名字
                MaxMemory     = 1024,                                  //最大内存,int类型
                Authenticator = new OfflineAuthenticator("incotnigo"), //离线启动,ZhaiSoul那儿为你要设置的游戏名
                                                                       //Authenticator = new YggdrasilLogin("邮箱", "密码", true), // 正版启动,最后一个为是否twitch登录
                Mode = LaunchMode.MCLauncher,

                Server = new ServerInfo {
                    Address = "180.101.116.73", Port = 31203
                },
                //Size = new WindowSize { Heighta = 768, Width = 1024 }
            });

            if (!result.Success)
            {
                MessageBox.Show(result.ErrorMessage, result.ErrorType.ToString());
                void NoJAVA(ErrorType results)
                {
                    MessageBox.Show("你系统的Java有异常,可能你非正常途径删除过Java,请尝试重新安装Java\n详细信息:" + result.ErrorMessage, "错误");
                }

                switch (result.ErrorType)
                {
                case ErrorType.NoJAVA:
                    NoJAVA(ErrorType.NoJAVA);
                    break;

                case ErrorType.AuthenticationFailed:
                    MessageBox.Show(this, "正版验证失败!请检查你的账号密码", "账号错误\n详细信息:" + result.ErrorMessage);
                    break;

                case ErrorType.UncompressingFailed:
                    MessageBox.Show(this, "可能的多开或文件损坏,请确认文件完整且不要多开\n如果你不是多开游戏的话,请检查libraries文件夹是否完整\n详细信息:" + result.ErrorMessage, "可能的多开或文件损坏");
                    break;

                default:
                    MessageBox.Show(this,
                                    result.ErrorMessage + "\n" +
                                    (result.Exception == null ? string.Empty : result.Exception.StackTrace),
                                    "启动错误,请将此窗口截图向开发者寻求帮助");
                    break;
                }
            }
        }
        private async void Asd_MouseDown(object sender, MouseButtonEventArgs e)
        {
            FolderBrowserDialog m_Dialog = new FolderBrowserDialog();
            DialogResult        result   = m_Dialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    paths    = m_Dialog.SelectedPath;
                    Asd.Text = "Minecraft  " + LauncherCore.Create(m_Dialog.SelectedPath).GetVersions().ToArray()[0].Assets;
                }
                catch { tit.Text = "无效的目录"; await Task.Delay(2000); tit.Text = ""; }
            }
        }
示例#7
0
    protected void LoadVersions()
    {
        LauncherCore core     = LauncherCore.Create();
        var          versions = core.GetVersions().Cast <KMCCC.Launcher.Version>();

        if (versions.Any())
        {
            foreach (KMCCC.Launcher.Version version in versions)
            {
                comboboxVersion.AppendText(version.Id);
            }
            comboboxVersion.Model.IterNthChild(out TreeIter iter, 0);
            comboboxVersion.SetActiveIter(iter);
        }
    }
        public LaunchResult Run()
        {
            var launchercore =
                LauncherCore.Create(new LauncherCoreCreationOption(javaPath: Config.Instance.JavaPath));

            launchercore.GameLog  += OnGameLog;
            launchercore.GameExit += (handle, i) =>
            {
                OnGameExit?.Invoke(handle, i);
                IsRunning = false;
            };
            var launchOptions = new LaunchOptions
            {
                Version       = launchercore.GetVersion(Definitions.ClientName),
                Authenticator = new OfflineAuthenticator(Config.Instance.PlayerAccount.Username),
                Mode          = LaunchMode.BmclMode,
                MaxMemory     = Config.Instance.MaxMemory
            };

            var result = launchercore.Launch(launchOptions, x =>
            {
                if (Config.Instance.JavaArguments.Contains("G1GC"))
                {
                    x.CGCEnabled = false;
                }
                x.AdvencedArguments.Add(Config.Instance.JavaArguments);
            });

            IsRunning = true;

            if (!result.Success)
            {
                OnError?.Invoke(result);
                IsRunning = false;
            }


            return(result);

            /*
             * result.Handle.GetPrivateField<Process>(nameof(Process)).Exited += (sender, args) =>
             * {
             *  IsRunning = false;
             *  OnGameExit?.Invoke();
             * };
             */
        }
示例#9
0
        private void InitializeLauncherCore()
        {
            Core           = LauncherCore.Create();
            Core.GameExit += OnGameExit;
            Core.GameLog  += OnGameLog;

            LoadVersions();

            var logPath = Core.GameRootPath + @"\logs\";

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            _logger = new StreamWriter(new FileStream(logPath + "mcrun.log", FileMode.Create));
        }
示例#10
0
 private static void Main()
 {
     using (_fs = new FileStream("mc.log", FileMode.Create))
     {
         using (_tw = new StreamWriter(_fs))
         {
             //这里图方便没有检验LauncherCoreCreationOption.Create()返回的是不是null
             var core = LauncherCore.Create();
             core.GameExit += core_GameExit;
             core.GameLog  += core_GameLog;
             var result = core.Launch(new LaunchOptions
             {
                 Version       = core.GetVersion("****"),
                 Authenticator = new OfflineAuthenticator("KBlackcn"),
                 //Authenticator = new YggdrasilLogin("****@****", "****", true),
                 //Server = new ServerInfo {Address = "mc.hypixel.net"},
                 Mode      = null,
                 MaxMemory = 2048,
                 MinMemory = 1024,
                 Size      = new WindowSize {
                     Height = 768, Width = 1280
                 }
             }, (Action <MinecraftLaunchArguments>)(x => { }));
             if (!result.Success)
             {
                 Console.WriteLine("启动失败:[{0}] {1}", result.ErrorType, result.ErrorMessage);
                 if (result.Exception != null)
                 {
                     Console.WriteLine(result.Exception.Message);
                     Console.WriteLine(result.Exception.Source);
                     Console.WriteLine(result.Exception.StackTrace);
                 }
                 Console.ReadKey();
                 return;
             }
             Are.WaitOne();
             Console.WriteLine("游戏已关闭");
             Console.ReadKey();
         }
     }
 }
示例#11
0
        private void Initialize_LauncherCore()
        {
            Core           = LauncherCore.Create();
            Core.GameExit += OnGameExit;
            Core.GameLog  += OnGameLog;

            uint count = 0;

            foreach (Version ver in Core.GetVersions())
            {
                Versions.Add(ver);
                count++;
            }

            if (count == 0)
            {
                Config.VersionIndex = -1;
            }
            else
            {
                if (Config.VersionIndex == -1 || Config.VersionIndex >= count)
                {
                    Config.VersionIndex = 0;
                }
            }

            var logPath = Core.GameRootPath + @"\logs\";

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            log_FileStream = new FileStream(logPath + "mcrun.log", FileMode.Create);
            Logger         = new StreamWriter(log_FileStream);
        }
示例#12
0
        private static void Main()
        {
            TestTimer Timer = new TestTimer();

            try
            {
                var a = MojangAPI.GetStatistics();
                Console.WriteLine(a.ToString() + "\n" + Timer.ToString());
                var api = MojangAPI.GetServiceStatus();
                foreach (var list in api)
                {
                    Console.WriteLine($"{list.Key} : {list.Value}");
                }

                Console.WriteLine("UUID:" + MojangAPI.NameToUUID("Notch") + "\n" + Timer.ToString());
            }
            catch (Exception ex)
            {
            }

            /*
             * try
             * {
             *  var ping = new ServerPing("mc.hypixel.net", 25565);
             *  var server = ping.Ping();
             *  Console.WriteLine(Timer.ToString());
             *  Console.WriteLine(server.description.text);
             *  Console.WriteLine("{0} / {1}", server.players.online, server.players.max);
             *  Console.WriteLine(server.version.name);
             *  Console.WriteLine(server.modinfo);
             *
             * }
             * catch(Exception ex)
             * {
             *  Console.WriteLine("服务器信息获取失败:"+ex.Message+"\n"+ Timer.ToString());
             * }
             */

            Console.WriteLine("初始化" + Timer.ToString());
            using (_fs = new FileStream("mc.log", FileMode.Create))
            {
                using (_tw = new StreamWriter(_fs))
                {
                    //这里图方便没有检验LauncherCoreCreationOption.Create()返回的是不是null
                    var core = LauncherCore.Create();
                    core.GameExit += core_GameExit;
                    core.GameLog  += core_GameLog;
                    Console.WriteLine("创建核心" + Timer.ToString());
                    var launch = new LaunchOptions
                    {
                        Version = core.GetVersion("1.13.2"),
                        //Authenticator = new YggdrasilRefresh(new Guid(),false),
                        Authenticator = new OfflineAuthenticator("test"),
                        //Authenticator = new YggdrasilValidate(Guid.Parse("****"), Guid.Parse("****"), Guid.Parse("****"), "***"),
                        //Authenticator = new YggdrasilLogin("***@**", "***", true,Guid.Parse("****")),
                        //Authenticator = new YggdrasilAuto("***@**", "***", null, null, null, null),
                        //Server = new ServerInfo {Address = "mc.hypixel.net"},
                        Mode      = null,
                        MaxMemory = 2048,
                        MinMemory = 1024,
                        Size      = new WindowSize {
                            Height = 768, Width = 1280
                        }
                    };
                    Console.WriteLine("设置参数" + Timer.ToString());
                    var result = core.Launch(launch, (Action <MinecraftLaunchArguments>)(x => { }));
                    Console.WriteLine("开启游戏" + Timer.ToString());
                    if (!result.Success)
                    {
                        Console.WriteLine("启动失败:[{0}] {1}", result.ErrorType, result.ErrorMessage);
                        if (result.Exception != null)
                        {
                            Console.WriteLine(result.Exception.Message);
                            Console.WriteLine(result.Exception.Source);
                            Console.WriteLine(result.Exception.StackTrace);
                        }
                        Console.ReadKey();
                        return;
                    }
                    Console.WriteLine($"AccessToken:{result.Handle.Info.AccessToken} " + "\n" + Timer.ToString());
                    GC.Collect(0);
                    Are.WaitOne();
                    Console.WriteLine("游戏已关闭");
                    result = null;
                    GC.Collect(0);
                    Console.ReadKey();
                }
            }
        }
示例#13
0
        public static bool AutoDownloadLibraries(string id, string usingApi)
        {
            try
            {
                var core    = LauncherCore.Create();
                var version = App.Core.GetVersion(id);
                var libs    = version.Libraries.Select(lib => core.GetLibPath(lib));

                List <string> file_path = new List <string>();

                var natives = version.Natives.Select(native => core.GetNativePath(native));
                foreach (string libflie in libs)
                {
                    if (!File.Exists(libflie))
                    {
                        file_path.Add(libflie.Replace("\\", "/").Replace(AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + ".minecraft/", ""));
                    }
                }
                foreach (string libflie in natives)
                {
                    if (!File.Exists(libflie))
                    {
                        file_path.Add(libflie.Replace("\\", "/").Replace(AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + ".minecraft/", ""));
                    }
                }

                string obj = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + ".minecraft/\n";
                foreach (string s in file_path)
                {
                    obj = obj + s + "\n";
                }

                List <DownloadFileTask> Task = new List <DownloadFileTask>();
                foreach (string file in file_path)
                {
                    string dir = ""; // 当前下载文件所在的相对目录 ("./minecraft/libraries/xxx")
                    dir = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/")
                          + ".minecraft/"
                          + file.Substring(0, file.LastIndexOf("/"))
                          + "/";
                    // 判断文件夹是否存在,不存在则创建
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    string savePath = ""; // 文件下载到的位置
                    savePath = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/")
                               + ".minecraft/"
                               + file;
                    string fileOnServerUrl = usingApi + "/" + file;
                    Task.Add(new DownloadFileTask(new FileInfo(file).Name, savePath, new Uri(fileOnServerUrl, UriKind.Absolute)));
                }

                MainWindow context = new MainWindow(new AquaL.Pages.FileDownload(Task));
                context.ShowDialog();
                return(true);
            }
            catch (Exception ex)
            {
                UI.MessageBox.QuickShow("Libraries下载失败!\n" + ex.Message, null);
                return(false);
            }
        }
示例#14
0
        private async void Btn_启动_Click(object sender, RoutedEventArgs e)
        {
            if (设置框.IsVisible)
            {
                Nosave();
                return;
            }
            Btn_启动.IsEnabled = false;
            runts.Text       = "正在启动中";
            runts.Visibility = Visibility.Visible;
            if (ListVersions.Items.Count == 0)
            {
                await this.ShowMessageAsync("无法启动游戏", "没有读取到游戏版本", MessageDialogStyle.Affirmative, new MetroDialogSettings()
                {
                    AffirmativeButtonText = "确定"
                });

                Btn_启动.IsEnabled = true;
                runts.Text       = null;
                load.Visibility  = Visibility.Hidden;
                return;
            }

            if (DownWindow.bgWorker.IsBusy)
            {
                //bgWorker.IsBusy await this.ShowMessageAsync("正在下载", "正在下载资源文件", MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = "确定" });
                // new downWindow { Owner = this }.ShowDialog();
                //downWindow.Showdown();
                downw.ShowDialog();
                //this.Hide();
                //down.Show();
            }
            else
            {
                runts.Text = "检查支持库";
                lostFlie.Clear();//清空列表,防止重新启动后,列表重复
                ver  = (Version)ListVersions.SelectedItem;
                core = LauncherCore.Create();
                var version = ver;//设置读取的版本配置为当前选择的项


                var jarid = ver.JarId;

                //      MessageBox.Show(core.GetVersionJsonPath(jarid));
                if (!File.Exists(core.GetVersionJsonPath(jarid)))
                {
                    Ts("无法启动游戏", "游戏核心不存在,请确认已选择正确的核心版本!");
                    runts.Visibility = Visibility.Hidden;
                    Btn_启动.Content   = "启动游戏";
                    load.Visibility  = Visibility.Hidden;
                    return;
                }
                try
                {
                    var libs = version.Libraries.Select(lib => core.GetLibPath(lib));

                    var natives = version.Natives.Select(native => core.GetNativePath(native));

                    foreach (string libflie in libs)
                    {
                        if (!File.Exists(libflie))
                        {
                            lostFlie.Add(libflie);
                            //  MessageBox.Show("当前缺少的Libraries文件有:" + file);
                        }
                    }
                    foreach (string libflie in natives)
                    {
                        if (!File.Exists(libflie))
                        {
                            lostFlie.Add(libflie);
                            //MessageBox.Show("当前缺少的Libraries-natives文件有:" + file);
                        }
                    }
                    if (lostFlie.Count != 0)
                    {
                        //返回一个值,中止继续执行后面的代码
                        new DownWindow {
                            Owner = this
                        }.ShowDialog();
                    }
                }
                catch
                {
                    Ts("无法启动游戏", "版本信息获取失败,无法读取所需的支持库,请确认已选择正确的核心版本!");
                    runts.Visibility = Visibility.Hidden;
                    Btn_启动.Content   = "启动游戏";
                    load.Visibility  = Visibility.Hidden;
                    return;
                }
                lostFlie.Clear();
                lostasset.Clear();
                lostlegacyasset.Clear();
                runts.Text = "检查资源文件";
                if (!Directory.Exists(rundir + ".minecraft/assets/indexes"))
                {
                    Directory.CreateDirectory(rundir + ".minecraft/assets/indexes");//创建文件夹
                }
                if (!Directory.Exists(rundir + ".minecraft/assets/objects"))
                {
                    Directory.CreateDirectory(rundir + ".minecraft/assets/objects");//创建文件夹
                }

                var    jsondir = core.GetVersionJsonPath(jarid);
                string json    = File.ReadAllText(jsondir);
                // MessageBox.Show(core.VersionLocator);
                JsonData data = JsonMapper.ToObject(json);
                string   type;
                string   url;
                try
                {
                    type = data["assetIndex"]["id"].ToString();
                    url  = data["assetIndex"]["url"].ToString().Replace("https://launchermeta.mojang.com", "http://download.mcbbs.net");
                    if (type != "legacy")
                    {
                        string jsonindex;

                        if (File.Exists(rundir + @".minecraft\assets\indexes\" + type + ".json"))
                        {
                            jsonindex = File.ReadAllText(rundir + @".minecraft\assets\indexes\" + type + ".json");
                        }
                        else
                        {
                            jsonindex = Beelogin.GetGeneralContent(url);
                            File.WriteAllText(rundir + @".minecraft\assets\indexes\" + type + ".json", jsonindex, Encoding.Default);
                        }
                        JsonData jdata = JsonMapper.ToObject(jsonindex);
                        jdata = jdata["objects"];
                        string hash;
                        string two;
                        string lj;
                        for (int i = 0; i < jdata.Count; i++)
                        {
                            hash = jdata[i]["hash"].ToString();
                            two  = hash.Substring(0, 2);
                            lj   = two + "\\" + hash;
                            if (!File.Exists(rundir + @".minecraft\assets\objects\" + lj))
                            {
                                lostasset.Add(hash);
                            }
                        }
                    }
                    else if (type == "legacy")
                    {
                        string jsonindex;
                        if (File.Exists(rundir + @".minecraft\assets\indexes\legacy.json"))
                        {
                            jsonindex = File.ReadAllText(rundir + ".minecraft/assets/indexes/legacy.json");
                        }
                        else
                        {
                            jsonindex = Beelogin.GetGeneralContent(url);
                        }
                        File.WriteAllText(rundir + @".minecraft\assets\indexes\legacy.json", jsonindex, Encoding.Default);
                        JObject jdata = (JObject)JsonConvert.DeserializeObject(jsonindex);
                        jdata = (JObject)jdata["objects"];
                        //  jdata = jdata["objects"];
                        foreach (var name in jdata)
                        {
                            //MessageBox.Show(rundir + @".minecraft\assets\" + name.Key);
                            if (!File.Exists(rundir + @".minecraft\assets\" + name.Key))
                            {
                                lostlegacyasset.Add(name.Key.Replace("/", "\\"));
                            }
                        }
                    }
                }
                catch
                {
                    type = data["assets"].ToString();
                    url  = "null";
                    if (type != "legacy")
                    {
                        string jsonindex;

                        if (File.Exists(rundir + @".minecraft\assets\indexes\" + type + ".json"))
                        {
                            jsonindex = File.ReadAllText(rundir + @".minecraft\assets\indexes\" + type + ".json");
                            JsonData jdata = JsonMapper.ToObject(jsonindex);
                            jdata = jdata["objects"];
                            string hash;
                            string two;
                            string lj;
                            for (int i = 0; i < jdata.Count; i++)
                            {
                                hash = jdata[i]["hash"].ToString();
                                two  = hash.Substring(0, 2);
                                lj   = two + "\\" + hash;
                                if (!File.Exists(rundir + @".minecraft\assets\objects\" + lj))
                                {
                                    lostasset.Add(hash);
                                }
                            }
                            lostassets = false;
                        }
                        else
                        {
                            lostassets = true;
                        }
                    }
                    else if (type == "legacy")
                    {
                        string jsonindex;
                        if (File.Exists(rundir + @".minecraft\assets\indexes\legacy.json"))
                        {
                            jsonindex = File.ReadAllText(rundir + ".minecraft/assets/indexes/legacy.json");
                            File.WriteAllText(rundir + @".minecraft\assets\indexes\legacy.json", jsonindex, Encoding.Default);
                            JObject jdata = (JObject)JsonConvert.DeserializeObject(jsonindex);
                            jdata = (JObject)jdata["objects"];
                            //  jdata = jdata["objects"];
                            foreach (var name in jdata)
                            {
                                //MessageBox.Show(rundir + @".minecraft\assets\" + name.Key);
                                if (!File.Exists(rundir + @".minecraft\assets\" + name.Key))
                                {
                                    lostlegacyasset.Add(name.Key.Replace("/", "\\"));
                                }
                            }
                            lostassets = false;
                        }
                        else
                        {
                            lostassets = true;
                        }
                    }
                }

                try
                {
                    if (lostasset.Count != 0 || lostlegacyasset.Count != 0)
                    {
                        if (url == "null")
                        {
                            await this.ShowMessageAsync("资源文件缺失", "发现缺少了" + (lostasset.Count != 0 ? lostasset.Count.ToString() : lostlegacyasset.Count != 0 ? lostlegacyasset.Count.ToString() : null) + "个资源文件,这可能导致游戏声音丢失\n但您的游戏核心版本较旧,不能自动补全.\n建议前往下载游戏窗口下载新版本客户端!", MessageDialogStyle.Affirmative, new MetroDialogSettings()
                            {
                                AffirmativeButtonText = "确定"
                            });

                            //   Ts("资源文件缺失", "发现缺少了" + (lostasset.Count != 0 ? lostasset.Count.ToString() : lostlegacyasset.Count != 0 ? lostlegacyasset.Count.ToString() : null) + "个资源文件,但您的游戏核心版本较旧,不能自动补全.\n建议前往下载游戏窗口下载新版本客户端!");
                        }
                        else
                        {
                            // new downWindow { Owner = this }.ShowDialog();

                            downw.Owner = this;
                            downw.ShowDialog();
                        }
                    }
                }
                catch
                {
                    //ts("错误", "尝试检查资源文件时失败,建议前往下载游戏窗口下载新版本客户端!");
                    lostassets = true;

                    // await this.ShowMessageAsync("错误", "尝试检查资源文件时失败,建议前往下载游戏窗口下载新版本客户端!", MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = "确定" });
                }
            }


            if (!bgWorker.IsBusy)
            {
                //MessageBox.Show("1");
                // bgWorker.CancelAsync();
                //bgWorker.Dispose();
                if (islaunch)
                {
                    bgWorker.RunWorkerAsync();
                }
                else
                {
                    bgWorker.WorkerReportsProgress = true;
                    bgWorker.ProgressChanged      += new ProgressChangedEventHandler(Bw_ProgressChanged);
                    bgWorker.RunWorkerCompleted   += new RunWorkerCompletedEventHandler(Bw_RunWorkerCompleted);
                    bgWorker.DoWork += new DoWorkEventHandler(Bw_DoWork1);
                    bgWorker.RunWorkerAsync();
                    islaunch = true;
                }
            }
        }
示例#15
0
        public static void VLW(Window window, string username, string password, string memory, string path, bool fullScreen)
        {
            LauncherCore core   = LauncherCore.Create();
            var          option = new LaunchOptions
            {
                Version   = core.GetVersion(VersionName),
                MaxMemory = Convert.ToInt32(memory),
                Mode      = LaunchMode.MCLauncher,
                Size      = new WindowSize
                {
                    Height = (ushort?)(Gdk.Screen.Default.Height / 2),
                    Width  = (ushort?)(Gdk.Screen.Default.Width / 2)
                }
            };

            if (fullScreen)
            {
                option.Size.FullScreen = true;
            }
#if ENABLE_TONGYI_AUTHENTICATION
            option.AgentPath     = "nide8auth.jar=" + ServerTongyiStr; // Chinese Third-party Authentication System: Minecraft 统一通行证
            option.Authenticator = new YggdrasilLogin(username, password, true, null, "https://auth2.nide8.com:233/" + ServerTongyiStr + "/authserver");
#else
            option.Authenticator = new OfflineAuthenticator(username);
#endif
            if (ServerIP.Length != 0)
            {
                option.Server = new ServerInfo {
                    Address = ServerIP, Port = ServerPort
                }
            }
            ;
            var result = core.Launch(option);
            if (!result.Success)
            {
                MessageDialog messageDialog;
                switch (result.ErrorType)
                {
                case ErrorType.NoJAVA:
                    messageDialog = new MessageDialog(window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Java Error, try to reinstall the client.")
                    {
                        Title = "Java Error"
                    };
                    break;

                case ErrorType.AuthenticationFailed:
                    messageDialog = new MessageDialog(window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Please check your username and password.")
                    {
                        Title = "Profile Error"
                    };
                    break;

                case ErrorType.UncompressingFailed:
                    messageDialog = new MessageDialog(window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Decompressing Failed!\n\nCheck your client or reinstall.")
                    {
                        Title = "Decompression Failure"
                    };
                    break;

                default:
                    messageDialog = new MessageDialog(window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, result.ErrorMessage + "\n" + (result.Exception == null ? string.Empty : result.Exception.StackTrace))
                    {
                        Title = "Unknown Error"
                    };
                    break;
                }
                messageDialog.Run();
            }
            Thread.Sleep(50);
        }
    }
示例#16
0
 public OneMCL(string WorkDirPath)
 {
     Core = LauncherCore.Create(WorkDirPath);
 }
示例#17
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + ".minecraft") && !Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + ".jre"))
            {
                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "jre.zip") && File.Exists(AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip"))
                {
                    tit.Text = "游戏数据加载中...(1/2)";
                    await Task.Run(new Action(delegate { UnZip(AppDomain.CurrentDomain.BaseDirectory + "jre.zip", AppDomain.CurrentDomain.BaseDirectory, ""); }));

                    tit.Text = "游戏数据加载中...(2/2)";
                    await Task.Run(new Action(delegate { UnZip(AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip", AppDomain.CurrentDomain.BaseDirectory, ""); }));

                    tit.Text = "";
                }
                else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "jre.zip") && !File.Exists(AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip"))
                {
                    tit.Text = "正在应用数据更改... (1/2)";
                    await Task.Run(new Action(delegate { UnZip(AppDomain.CurrentDomain.BaseDirectory + "jre.zip", AppDomain.CurrentDomain.BaseDirectory, ""); }));

                    var s = new WebClient();
                    s.DownloadFileAsync(new Uri("http://pan.kzwr.com/kzwrfs?fid=dde342eefa164bec8a45408ce25ccfd1bzo1.zip"), AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip");
                    s.DownloadProgressChanged += delegate(object se, DownloadProgressChangedEventArgs es) { tit.Text = "下载游戏数据中...    " + (es.ProgressPercentage) + "%   (2/2)"; };
                    s.DownloadFileCompleted   += async delegate
                    {
                        tit.Text = "正在应用数据更改... (2/2)";
                        await Task.Run(new Action(delegate { UnZip(AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip", AppDomain.CurrentDomain.BaseDirectory, ""); }));

                        s.Dispose();
                    };
                }
                else
                {
                    tit.Text = "下载游戏数据中...";
                    System.Net.WebClient w = new System.Net.WebClient();
                    w.DownloadFileAsync(new Uri("http://pan.kzwr.com/kzwrfs?fid=c63a5591bce6404198b66e84ca36ecb0317r.zip"), AppDomain.CurrentDomain.BaseDirectory + "jre.zip");
                    w.DownloadProgressChanged += delegate(object se, DownloadProgressChangedEventArgs es) { tit.Text = "下载游戏数据中...    " + (es.ProgressPercentage) + "%   (1/2)"; };
                    w.DownloadFileCompleted   += async delegate
                    {
                        tit.Text = "正在应用数据更改... (1/2)";
                        await Task.Run(new Action(delegate { UnZip(AppDomain.CurrentDomain.BaseDirectory + "jre.zip", AppDomain.CurrentDomain.BaseDirectory, ""); }));

                        w.Dispose();
                        var s = new WebClient();
                        s.DownloadFileAsync(new Uri("http://pan.kzwr.com/kzwrfs?fid=dde342eefa164bec8a45408ce25ccfd1bzo1.zip"), AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip");
                        s.DownloadProgressChanged += delegate(object se, DownloadProgressChangedEventArgs es) { tit.Text = "下载游戏数据中...    " + (es.ProgressPercentage) + "%   (2/2)"; };
                        s.DownloadFileCompleted   += async delegate
                        {
                            tit.Text = "正在应用数据更改... (2/2)";
                            await Task.Run(new Action(delegate { UnZip(AppDomain.CurrentDomain.BaseDirectory + ".minecraft.zip", AppDomain.CurrentDomain.BaseDirectory, ""); }));

                            s.Dispose();
                            tit.Text = "";
                            try
                            {
                                if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + ".minecraft") && Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + ".jre"))
                                {
                                    Asd.Text = "Minecraft  " + LauncherCore.Create().GetVersions().ToArray()[0].Assets;
                                }
                            }
                            catch { Asd.Text = "没有检测到MC,点我添加"; }
                        };
                    };
                }
            }
        }