Example #1
0
        public Process Start(Server server)
        {
            System.Net.ServicePointManager.DefaultConnectionLimit = 256;

            var game     = new MinecraftPath(path);
            var launcher = new CMLauncher(game);

            launcher.ProgressChanged += Download_Progress;
            launcher.FileChanged     += Download_ChangeFile;

            string version = "";

            if (server.TYPE == "forge")
            {
                version = FindForgeVersion(server.VERSION);

                if (version == "")
                {
                    return(null);
                }
            }
            else
            {
                version = server.VERSION;
            }

            var lv = new LocalVersionLoader(game).GetVersionMetadatas();

            var findVersion = lv.GetVersion(version);

            if (findVersion == null)
            {
                var findMVersion = lv.GetVersionMetadata(version);

                if (findMVersion != null)
                {
                    findMVersion.Save(game);
                }
                else
                {
                    var findWVersion = new MojangVersionLoader().GetVersionMetadatas().GetVersionMetadata(version);

                    if (findWVersion != null)
                    {
                        findWVersion.Save(game);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            var launchOption = new MLaunchOption
            {
                ServerIp            = server.IP,
                ServerPort          = server.PORT,
                MaximumRamMb        = ram,
                Session             = se,
                Path                = game,
                StartVersion        = findVersion,
                GameLauncherName    = "JML",
                GameLauncherVersion = "1.0"
            };

            var process = launcher.CreateProcess(launchOption);

            process.Start();

            return(process);
        }
Example #2
0
        public Process Start(string _version)
        {
            System.Net.ServicePointManager.DefaultConnectionLimit = 256;

            var game     = new MinecraftPath(path);
            var launcher = new CMLauncher(game);

            launcher.ProgressChanged += Download_Progress;
            launcher.FileChanged     += Download_ChangeFile;

            var lv = new LocalVersionLoader(game).GetVersionMetadatas();

            MVersion findVersion = null;

            try
            {
                findVersion = lv.GetVersion(_version);
            }
            catch (KeyNotFoundException)
            {
            }


            //var findVersion = lv.GetVersion(_version);

            if (findVersion == null)
            {
                MVersionMetadata findMVersion = null;

                try
                {
                    findMVersion = lv.GetVersionMetadata(_version);
                }
                catch (KeyNotFoundException)
                {
                }

                if (findMVersion != null)
                {
                    findMVersion.Save(game);
                }
                else
                {
                    var findWVersion = new MojangVersionLoader().GetVersionMetadatas().GetVersionMetadata(_version);

                    if (findWVersion != null)
                    {
                        findWVersion.Save(game);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            try
            {
                findVersion = lv.GetVersion(_version);
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }

            var launchOption = new MLaunchOption
            {
                MaximumRamMb        = ram,
                Session             = se,
                Path                = game,
                StartVersion        = findVersion,
                GameLauncherName    = "JML",
                GameLauncherVersion = "1.0"
            };

            MLaunch launch  = new MLaunch(launchOption);
            var     process = launch.GetProcess();

            process.Start();

            //Process process = launcher.CreateProcess(launchOption);
            //process.Start();

            return(process);
        }