示例#1
0
 public Updater(string dir)
 {
     if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
     Directory.SetCurrentDirectory(dir);
     vars = new Dictionary<string, string>();
     overrides = new Dictionary<string, string>();
     mirrorlist = new List<string>();
     this.ResetMirrors();
     this.updwindow = null;
 }
示例#2
0
 public void UpdateMinecraft()
 {
     this.UpdateStatus("Updajtam iz verzije: " + this.GetCurrentVersion());
     this.DownloadFile("ver", ".temp");
     this.UpdateStatus("Zaganjam update file...");
     overrides.Clear();
     this.progress = true;
     ExecuteCode(".temp");
     File.Delete(".temp");
     this.updwindow = null;
 }
示例#3
0
 public Updater(string dir)
 {
     if (!Directory.Exists(dir))
     {
         Directory.CreateDirectory(dir);
     }
     Directory.SetCurrentDirectory(dir);
     vars       = new Dictionary <string, string>();
     overrides  = new Dictionary <string, string>();
     mirrorlist = new List <string>();
     this.ResetMirrors();
     this.updwindow = null;
 }
示例#4
0
 private bool testForMinecraftUpdate(Updater upd)
 {
     try
     {
         upd.updwindow = null;
         upd.DownloadFile("update", null, false);
         UpdateWindow updater = new UpdateWindow();
         updater.upd   = upd;
         upd.updwindow = updater;
         updater.RunUpdate();
         if (!updater.update_success)
         {
             MessageBox.Show("Update neuspešen. Zadnja napaka: " + updater.update_error + "\nZa dodatna pojasnila prosim kontaktiraj admine!");
             Application.Exit();
             Environment.Exit(0);
         }
         return(true);
     }
     catch { };
     return(false);
 }
示例#5
0
 public void UpdateMinecraft()
 {
     this.UpdateStatus("Updajtam iz verzije: " + this.GetCurrentVersion());
     this.DownloadFile("ver", ".temp");
     this.UpdateStatus("Zaganjam update file...");
     overrides.Clear();
     this.progress = true;
     ExecuteCode(".temp");
     File.Delete(".temp");
     this.updwindow = null;
 }
示例#6
0
 private bool testForMinecraftUpdate(Updater upd)
 {
     try
     {
         upd.updwindow = null;
         upd.DownloadFile("update", null, false);
         UpdateWindow updater = new UpdateWindow();
         updater.upd = upd;
         upd.updwindow = updater;
         updater.RunUpdate();
         if (!updater.update_success)
         {
             MessageBox.Show("Update neuspešen. Zadnja napaka: " + updater.update_error + "\nZa dodatna pojasnila prosim kontaktiraj admine!");
             Application.Exit();
             Environment.Exit(0);
         }
         return true;
     }
     catch { };
     return false;
 }
示例#7
0
 public Form1()
 {
     InitializeComponent();
     variables = new VarStorage();
     variables.SetValue("version", version);
     ConsoleLogger.debugscreen = new DebugScr();
     ConsoleLogger.debugscreen.Show();
     bool hide = true;
     string chdir = "";
     if ((File.Exists("ll-debugme")) || (File.Exists("ll-debugme.txt"))) hide = false;
     if (Environment.GetCommandLineArgs().Length >= 2)
     {
         string[] cmdline = Environment.GetCommandLineArgs();
         int i = 1;
         while (i < cmdline.Length)
         {
           	if (cmdline[i] == "--debug") hide = false;
           	else if (cmdline[i] == "--dir") chdir = cmdline[(i+1)];
               i++;
         }
     }
     if (hide) ConsoleLogger.debugscreen.Hide();
     this.KeyPreview = true;
     ConsoleLogger.LogData("LL " + Form1.version + " @ " + Environment.GetCommandLineArgs()[0], "Main");
     ConsoleLogger.LogData("Environment fingerprint: " + getFingerprint());
     dec = -50;
     offline = false;
     hasjava = false;
     Updater upd = new Updater(".");
     loonix = Updater.IsLoonix();
     string os = "Windoze";
     javaname = "java";
     string fd = "\\";
     if (loonix)
     {
         fd = "/";
         os = "Linux";
     }
     variables.SetValue("fd", fd);
     string installpath = "";
     string tempdir = "";
     if (!loonix)
     {
         installpath = Environment.GetEnvironmentVariable("APPDATA") + fd + "LameCraft";
         tempdir = Environment.GetEnvironmentVariable("TEMP");
     }
     else
     {
         installpath = Environment.GetEnvironmentVariable("HOME") + fd + ".LameCraft";
         tempdir = "/tmp";
     }
     if (chdir != "") installpath = chdir;
     variables.SetValue("lldir", installpath);
     ConsoleLogger.LogData("OS: " + os, "Main");
     ConsoleLogger.LogData("MCIP: " + installpath, "Main");
     ConsoleLogger.LogData("TMP: " + tempdir, "Main");
     if (!Directory.Exists(installpath)) Directory.CreateDirectory(installpath);
     Directory.SetCurrentDirectory(installpath);
     config = new ConfigFile("launcher.cfg");
     label4.Text = "LameLauncher version: " + version + ", Minecraft: " + upd.GetCurrentVersion() + ", " + os;
     button3.Location = new Point(button3.Location.X + 400, button3.Location.Y);
     button2.Location = new Point(button2.Location.X + 400, button2.Location.Y);
     label5.Location = new Point(label5.Location.X + 400, label5.Location.Y);
     textBox3.Location = new Point(textBox3.Location.X + 400, textBox3.Location.Y);
     DetectJava();
     if (hasjava) label6.Hide();
     if (config.GetValue("offlinemode", "0") == "0")
     {
         try
         {
             ConsoleLogger.LogData("Cekiram dosegljivost auth serverja...", "Main");
             upd.GetHTTPFile("https://minecraft.knuples.net/auth.php?ping=1", tempdir + fd + "deleteme.mclauncher.auth.chk", 1500);
             File.Delete(tempdir + fd + "deleteme.mclauncher.update.chk");
         }
         catch (Exception e)
         {
             ConsoleLogger.LogData("*** AUTH SERVER NEDOSEGLJIV ***", "Main");
             ConsoleLogger.LogData(e.Message, "Main");
             ConsoleLogger.LogData("Delujem v offline nacinu!", "Main");
             offline = true;
         }
         if ((config.GetValue("chkupdate", "1") == "1") && (!offline))
         {
             bool isupdate = false;
             try
             {
                 // This is so important, we can't mess this up!
                 ConsoleLogger.LogData("Cekiram za update launcherja...", "Main");
                 upd.GetHTTPFile("https://minecraft.knuples.net/updates/launcher/" + version + "." + os, tempdir + fd + "deleteme.mclauncher.update.chk" + version, 300, 1);
                 File.Delete(tempdir + fd + "deleteme.mclauncher.update.chk");
                 UpdateWindow uw = new UpdateWindow();
                 uw.NewStatus("Launcher ima nov update, downloadam...");
                 ConsoleLogger.LogData("Launcher ima nov update!", "Main");
                 isupdate = true;
                 uw.runthread = false;
                 uw.Show();
                 Application.DoEvents();
                 string ofile = tempdir + fd + "deleteme." + version + "mclauncher.update.exe";
                 Application.DoEvents();
                 upd.GetHTTPFile("https://minecraft.knuples.net/updates/launcher/" + version + "." + os + ".bin", ofile, 1000);
                 uw.Hide();
                 System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                 startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                 startInfo.FileName = ofile;
                 startInfo.Arguments = Environment.GetCommandLineArgs()[0];
                 System.Diagnostics.Process proc = new System.Diagnostics.Process();
                 proc.StartInfo = startInfo;
                 proc.Start();
                 Application.Exit();
                 Environment.Exit(0);
             }
             catch {
                 /** WTF JE BLO TO, SHIT, SHIT, SHIT, DO TEGA NEBI SMELO PRIT!
                     Konec je z nami, fertik smo, adijo, zbrisi system32 in zvali krivdo
                     na Windowse. Po možnosti poišči še vse .doc in .jpg fajle in jih zbriši,
                     da se bo mel user za kaj sekirat, razen tega kak ne more minecrafta igrat **/
                 if (isupdate)
                 {
                     MessageBox.Show("Poskusal downloadat update, ampak mi nekako ni uspelo.\nProsim, prenesi update s strani!");
                     Environment.Exit(1);
                 }
                 /* Ali pa crashni aplikacijo. Jup, to bi tudi šlo. */
                 Application.Exit();
             }
             int ntries = 0;
             while (testForMinecraftUpdate(upd))
             {
                 ntries++;
                 ConsoleLogger.LogData("Retesting for update...");
                 if (ntries > 10)
                 {
                     MessageBox.Show("Dal že deset iteracij poskusa updejta skozi. Nekaj je hudo narobe.\nProsim kontaktiraj admine!");
                     Application.Exit();
                     Environment.Exit(0);
                 }
             }
         }
     }
     else
     {
         ConsoleLogger.LogData("Hoces offline nacin? Tudi prav!", "Main");
         offline = true;
     }
     if (offline)
     {
         checkBox2.Visible = false;
         linkLabel1.Visible = false;
         label7.Visible = true;
         checkBox1.Location = new Point(171, checkBox1.Location.Y);
     }
     if (config.GetValue("remember", "1") == "1")
     {
         textBox1.Text = config.GetValue("user", "");
         textBox2.Text = config.GetValue("pass", "");
         checkBox1.Checked = true;
     }
     if (config.GetValue("autologin", "1") == "1") checkBox2.Checked = true;
     ConsoleLogger.LogData("Init koncan, fire away!", "Main");
 }
示例#8
0
        public Form1()
        {
            InitializeComponent();
            variables = new VarStorage();
            variables.SetValue("version", version);
            ConsoleLogger.debugscreen = new DebugScr();
            ConsoleLogger.debugscreen.Show();
            bool   hide  = true;
            string chdir = "";

            if ((File.Exists("ll-debugme")) || (File.Exists("ll-debugme.txt")))
            {
                hide = false;
            }
            if (Environment.GetCommandLineArgs().Length >= 2)
            {
                string[] cmdline = Environment.GetCommandLineArgs();
                int      i       = 1;
                while (i < cmdline.Length)
                {
                    if (cmdline[i] == "--debug")
                    {
                        hide = false;
                    }
                    else if (cmdline[i] == "--dir")
                    {
                        chdir = cmdline[(i + 1)];
                    }
                    i++;
                }
            }
            if (hide)
            {
                ConsoleLogger.debugscreen.Hide();
            }
            this.KeyPreview = true;
            ConsoleLogger.LogData("LL " + Form1.version + " @ " + Environment.GetCommandLineArgs()[0], "Main");
            ConsoleLogger.LogData("Environment fingerprint: " + getFingerprint());
            dec     = -50;
            offline = false;
            hasjava = false;
            Updater upd = new Updater(".");

            loonix = Updater.IsLoonix();
            string os = "Windoze";

            javaname = "java";
            string fd = "\\";

            if (loonix)
            {
                fd = "/";
                os = "Linux";
            }
            variables.SetValue("fd", fd);
            string installpath = "";
            string tempdir     = "";

            if (!loonix)
            {
                installpath = Environment.GetEnvironmentVariable("APPDATA") + fd + "LameCraft";
                tempdir     = Environment.GetEnvironmentVariable("TEMP");
            }
            else
            {
                installpath = Environment.GetEnvironmentVariable("HOME") + fd + ".LameCraft";
                tempdir     = "/tmp";
            }
            if (chdir != "")
            {
                installpath = chdir;
            }
            variables.SetValue("lldir", installpath);
            ConsoleLogger.LogData("OS: " + os, "Main");
            ConsoleLogger.LogData("MCIP: " + installpath, "Main");
            ConsoleLogger.LogData("TMP: " + tempdir, "Main");
            if (!Directory.Exists(installpath))
            {
                Directory.CreateDirectory(installpath);
            }
            Directory.SetCurrentDirectory(installpath);
            config            = new ConfigFile("launcher.cfg");
            label4.Text       = "LameLauncher version: " + version + ", Minecraft: " + upd.GetCurrentVersion() + ", " + os;
            button3.Location  = new Point(button3.Location.X + 400, button3.Location.Y);
            button2.Location  = new Point(button2.Location.X + 400, button2.Location.Y);
            label5.Location   = new Point(label5.Location.X + 400, label5.Location.Y);
            textBox3.Location = new Point(textBox3.Location.X + 400, textBox3.Location.Y);
            DetectJava();
            if (hasjava)
            {
                label6.Hide();
            }
            if (config.GetValue("offlinemode", "0") == "0")
            {
                try
                {
                    ConsoleLogger.LogData("Cekiram dosegljivost auth serverja...", "Main");
                    upd.GetHTTPFile("https://minecraft.knuples.net/auth.php?ping=1", tempdir + fd + "deleteme.mclauncher.auth.chk", 1500);
                    File.Delete(tempdir + fd + "deleteme.mclauncher.update.chk");
                }
                catch (Exception e)
                {
                    ConsoleLogger.LogData("*** AUTH SERVER NEDOSEGLJIV ***", "Main");
                    ConsoleLogger.LogData(e.Message, "Main");
                    ConsoleLogger.LogData("Delujem v offline nacinu!", "Main");
                    offline = true;
                }
                if ((config.GetValue("chkupdate", "1") == "1") && (!offline))
                {
                    bool isupdate = false;
                    try
                    {
                        // This is so important, we can't mess this up!
                        ConsoleLogger.LogData("Cekiram za update launcherja...", "Main");
                        upd.GetHTTPFile("https://minecraft.knuples.net/updates/launcher/" + version + "." + os, tempdir + fd + "deleteme.mclauncher.update.chk" + version, 300, 1);
                        File.Delete(tempdir + fd + "deleteme.mclauncher.update.chk");
                        UpdateWindow uw = new UpdateWindow();
                        uw.NewStatus("Launcher ima nov update, downloadam...");
                        ConsoleLogger.LogData("Launcher ima nov update!", "Main");
                        isupdate     = true;
                        uw.runthread = false;
                        uw.Show();
                        Application.DoEvents();
                        string ofile = tempdir + fd + "deleteme." + version + "mclauncher.update.exe";
                        Application.DoEvents();
                        upd.GetHTTPFile("https://minecraft.knuples.net/updates/launcher/" + version + "." + os + ".bin", ofile, 1000);
                        uw.Hide();
                        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                        startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                        startInfo.FileName    = ofile;
                        startInfo.Arguments   = Environment.GetCommandLineArgs()[0];
                        System.Diagnostics.Process proc = new System.Diagnostics.Process();
                        proc.StartInfo = startInfo;
                        proc.Start();
                        Application.Exit();
                        Environment.Exit(0);
                    }
                    catch {
                        /** WTF JE BLO TO, SHIT, SHIT, SHIT, DO TEGA NEBI SMELO PRIT!
                         *  Konec je z nami, fertik smo, adijo, zbrisi system32 in zvali krivdo
                         *  na Windowse. Po možnosti poišči še vse .doc in .jpg fajle in jih zbriši,
                         *  da se bo mel user za kaj sekirat, razen tega kak ne more minecrafta igrat **/
                        if (isupdate)
                        {
                            MessageBox.Show("Poskusal downloadat update, ampak mi nekako ni uspelo.\nProsim, prenesi update s strani!");
                            Environment.Exit(1);
                        }
                        /* Ali pa crashni aplikacijo. Jup, to bi tudi šlo. */
                        Application.Exit();
                    }
                    int ntries = 0;
                    while (testForMinecraftUpdate(upd))
                    {
                        ntries++;
                        ConsoleLogger.LogData("Retesting for update...");
                        if (ntries > 10)
                        {
                            MessageBox.Show("Dal že deset iteracij poskusa updejta skozi. Nekaj je hudo narobe.\nProsim kontaktiraj admine!");
                            Application.Exit();
                            Environment.Exit(0);
                        }
                    }
                }
            }
            else
            {
                ConsoleLogger.LogData("Hoces offline nacin? Tudi prav!", "Main");
                offline = true;
            }
            if (offline)
            {
                checkBox2.Visible  = false;
                linkLabel1.Visible = false;
                label7.Visible     = true;
                checkBox1.Location = new Point(171, checkBox1.Location.Y);
            }
            if (config.GetValue("remember", "1") == "1")
            {
                textBox1.Text     = config.GetValue("user", "");
                textBox2.Text     = config.GetValue("pass", "");
                checkBox1.Checked = true;
            }
            if (config.GetValue("autologin", "1") == "1")
            {
                checkBox2.Checked = true;
            }
            ConsoleLogger.LogData("Init koncan, fire away!", "Main");
        }