Exemple #1
0
        public static void DosOn(string account, string Version, string javapath, string password, int MaxMem, int MinMem, bool FullScreen, ushort high, ushort width)
        {
            TestTimer Timer = new TestTimer();

            OtherJava = javapath;

            /*
             * 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());
             * }
             */

            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 launch = new LaunchOptions
                    {
                        Version = core.GetVersion(Version),
                        //Authenticator = new YggdrasilRefresh(new Guid(),false),
                        //Authenticator = new OfflineAuthenticator(name),
                        //Authenticator = new YggdrasilValidate(Guid.Parse("****"), Guid.Parse("****"), Guid.Parse("****"), "***"),
                        //Authenticator = new YggdrasilLogin("***@**", "***", true,Guid.Parse("****")),
                        Authenticator = new YggdrasilAuto(account, password, null, null, null, null),
                        //Server = new ServerInfo {Address = "mc.hypixel.net"},
                        Mode      = null,
                        MaxMemory = MaxMem,
                        MinMemory = MinMem,
                        Size      = new WindowSize {
                            FullScreen = FullScreen, Height = high, Width = width
                        }
                    };
                    var result = core.Launch(launch, (Action <MinecraftLaunchArguments>)(x => { }));
                    GC.Collect(0);
                    Are.WaitOne();
                    result = null;
                    GC.Collect(0);
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///     从CreationOption创建启动器核心
        /// </summary>
        /// <param name="option">启动器创建选项</param>
        /// <returns>创建的启动器核心</returns>
        public static LauncherCore Create(LauncherCoreCreationOption option)
        {
            var launcherCore = new LauncherCore
            {
                GameRootPath   = option.GameRootPath,
                JavaPath       = option.JavaPath,
                VersionLocator = option.VersionLocator
            };

            return(launcherCore);
        }
Exemple #3
0
 public override bool Operate(LauncherCore core, MinecraftLaunchArguments args)
 {
     return(_operatorMethod.Invoke(core, args));
 }
Exemple #4
0
 public override bool Operate(LauncherCore core, MinecraftLaunchArguments args)
 {
     args.Tokens["game_directory"] = String.Format(@".\versions\{0}\", args.Version.Id);
     return(true);
 }
Exemple #5
0
 /// <summary>
 ///     启动模式
 /// </summary>
 /// <returns>模式是否应用成功</returns>
 public abstract bool Operate(LauncherCore core, MinecraftLaunchArguments args);
Exemple #6
0
 public static string GetNativePath(this LauncherCore core, Native native)
 {
     return(String.Format(@"{0}\libraries\{1}\{2}\{3}\{2}-{3}-{4}.jar", core.GameRootPath, native.NS.Replace(".", "\\"), native.Name, native.Version,
                          native.NativeSuffix));
 }
Exemple #7
0
 public static string GetLibPath(this LauncherCore core, Library lib)
 {
     return(String.Format(@"{0}\libraries\{1}\{2}\{3}\{2}-{3}.jar", core.GameRootPath, lib.NS.Replace(".", "\\"), lib.Name, lib.Version));
 }
Exemple #8
0
 public static string GetVersionOptions(this LauncherCore core, string versionId)
 {
     return(String.Format(@"{0}\versions\{1}\options.txt", core.GameRootPath, versionId));
 }
Exemple #9
0
 public static string GetVersionOptions(this LauncherCore core, Version version)
 {
     return(GetVersionOptions(core, version.Id));
 }
Exemple #10
0
 public static string GetVersionJsonPath(this LauncherCore core, string versionId)
 {
     return(String.Format(@"{0}\versions\{1}\{1}.json", core.GameRootPath, versionId));
 }
Exemple #11
0
 public static string GetVersionJsonPath(this LauncherCore core, Version version)
 {
     return(GetVersionJsonPath(core, version.Id));
 }