JohnDong

Minecraft Launcher DLL

Aug 24th, 2012
4,495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. //Additional includes
  7. using System.IO;
  8. using System.Net;
  9. using System.Diagnostics;
  10. using System.Windows.Forms;
  11.  
  12. namespace MCLoginLib
  13. {
  14.     public class Login
  15.     {
  16.         /// <summary>
  17.         /// Used to generate a session with login.minecraft.net for online use only
  18.         /// </summary>
  19.         /// <param name="username">The player's username</param>
  20.         /// <param name="password">The player's password</param>
  21.         /// <param name="clientVer">The client version (look here http://wiki.vg/Session)</param>
  22.         /// <returns>Returns 5 values split by ":" Current Version : Download Ticket : Username : Session ID : UID</returns>
  23.         public static string generateSession(string username, string password, int clientVer)
  24.         {
  25.             string netResponse = httpGET("https://login.minecraft.net?user=" + username + "&password=" + password + "&version=" + clientVer);
  26.             return netResponse;
  27.         }
  28.  
  29.         public static string httpGET(string URI)
  30.         {
  31.             WebRequest req = WebRequest.Create(URI);
  32.             WebResponse resp = req.GetResponse();
  33.             StreamReader sr = new StreamReader(resp.GetResponseStream());
  34.             return sr.ReadToEnd().Trim();
  35.         }
  36.  
  37.         /// <summary>
  38.         /// Used to start minecraft with certain arguments
  39.         /// </summary>
  40.         /// <param name="mode">True for online and false for offline</param>
  41.         /// <param name="ramMin">Equivalent to the -Xms argument</param>
  42.         /// <param name="ramMax">Equivalent to the -Xmx argument</param>
  43.         /// <param name="username">The player's username</param>
  44.         /// <param name="sessionID">The session id generated from login.minecraft.net</param>
  45.         /// <param name="debug">True for console boot and false for no console</param>
  46.         public static void startMinecraft(bool mode, int ramMin, int ramMax, string username, string sessionID, bool debug)
  47.         {
  48.             string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\";
  49.             string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\";
  50.             Process proc = new Process();
  51.             if (debug == true)
  52.             {
  53.                 proc.StartInfo.FileName = "java";
  54.             }
  55.             else
  56.             {
  57.                 proc.StartInfo.FileName = "javaw";
  58.             }
  59.  
  60.             //Online and offline modes
  61.             if (mode == true)
  62.             {
  63.                 proc.StartInfo.Arguments = "-Xms" + ramMin + "M -Xmx" + ramMax + "M -Djava.library.path=" + appData + ".minecraft/bin/natives -cp " + appData + ".minecraft/bin/minecraft.jar;" + appData + ".minecraft/bin/jinput.jar;" + appData + ".minecraft/bin/lwjgl.jar;" + appData + ".minecraft/bin/lwjgl_util.jar net.minecraft.client.Minecraft " + username + " " + sessionID;
  64.             }
  65.             else
  66.             {
  67.                 proc.StartInfo.Arguments = "-Xms" + ramMin + "M -Xmx" + ramMax + "M -Djava.library.path=" + appData + ".minecraft/bin/natives -cp " + appData + ".minecraft/bin/minecraft.jar;" + appData + ".minecraft/bin/jinput.jar;" + appData + ".minecraft/bin/lwjgl.jar;" + appData + ".minecraft/bin/lwjgl_util.jar net.minecraft.client.Minecraft " + username;
  68.             }
  69.             proc.Start();
  70.         }
  71.     }
  72. }
Add Comment
Please, Sign In to add comment