Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.03 KB | None | 0 0
  1. //
  2. // Decompiled by Procyon v0.5.30
  3. //
  4.  
  5. package net.minecraft;
  6.  
  7. import java.awt.BorderLayout;
  8. import java.awt.Color;
  9. import java.awt.Dimension;
  10. import java.awt.Frame;
  11. import java.awt.event.WindowAdapter;
  12. import java.awt.event.WindowEvent;
  13. import java.io.File;
  14. import java.io.IOException;
  15. import java.lang.reflect.Constructor;
  16. import java.net.Authenticator;
  17. import java.net.InetSocketAddress;
  18. import java.net.PasswordAuthentication;
  19. import java.net.Proxy;
  20. import java.net.URL;
  21. import java.net.URLClassLoader;
  22. import java.util.HashMap;
  23. import java.util.Map;
  24.  
  25. import javax.imageio.ImageIO;
  26. import javax.swing.JFrame;
  27. import javax.swing.JPanel;
  28. import javax.swing.UIManager;
  29.  
  30. import joptsimple.OptionException;
  31. import joptsimple.OptionParser;
  32. import joptsimple.OptionSet;
  33. import joptsimple.OptionSpec;
  34.  
  35. public class LauncherFrame extends Frame
  36. {
  37.     public static final int VERSION = 13;
  38.     private static final long serialVersionUID = 1L;
  39.     public Map<String, String> customParameters;
  40.     public Launcher launcher;
  41.     public LoginForm loginForm;
  42.    
  43.     public LauncherFrame() {
  44.         super("Minecraft Launcher (fixed by ya boi skoolshooter) OS: " + System.getProperty("os.name"));
  45.         this.customParameters = new HashMap<String, String>();
  46.         this.setBackground(Color.BLACK);
  47.         this.loginForm = new LoginForm(this);
  48.         final JPanel panel = new JPanel();
  49.         panel.setLayout(new BorderLayout());
  50.         panel.add(this.loginForm, "Center");
  51.         panel.setPreferredSize(new Dimension(854, 480));
  52.         this.setLayout(new BorderLayout());
  53.         this.add(panel, "Center");
  54.         this.pack();
  55.         this.setLocationRelativeTo(null);
  56.         try {
  57.             this.setIconImage(ImageIO.read(LauncherFrame.class.getResource("favicon.png")));
  58.         }
  59.         catch (IOException ex) {
  60.             ex.printStackTrace();
  61.         }
  62.         this.addWindowListener(new WindowAdapter() {
  63.             public void windowClosing(final WindowEvent windowEvent) {
  64.                 new Thread() {
  65.                     public void run() {
  66.                         try {
  67.                             Thread.sleep(30000L);
  68.                         }
  69.                         catch (InterruptedException ex) {
  70.                             ex.printStackTrace();
  71.                         }
  72.                         System.out.println("FORCING EXIT!");
  73.                         System.exit(0);
  74.                     }
  75.                 }.start();
  76.                 if (LauncherFrame.this.launcher != null) {
  77.                     LauncherFrame.this.launcher.stop();
  78.                     LauncherFrame.this.launcher.destroy();
  79.                 }
  80.                 System.exit(0);
  81.             }
  82.         });
  83.     }
  84.    
  85.     public void playCached(String s, final boolean b) {
  86.         try {
  87.             if (s == null || s.length() <= 0) {
  88.                 s = "Player";
  89.             }
  90.             this.launcher = new Launcher();
  91.             this.launcher.customParameters.putAll(this.customParameters);
  92.             this.launcher.customParameters.put("userName", s);
  93.             this.launcher.customParameters.put("demo", "" + b);
  94.             this.launcher.customParameters.put("sessionId", "1");
  95.             this.launcher.init();
  96.             this.removeAll();
  97.             this.add(this.launcher, "Center");
  98.             this.validate();
  99.             this.launcher.start();
  100.             this.loginForm = null;
  101.             this.setTitle("Minecraft");
  102.         }
  103.         catch (Exception ex) {
  104.             ex.printStackTrace();
  105.             this.showError(ex.toString());
  106.         }
  107.     }
  108.    
  109.     public void login(final String s, final String s2) {
  110.         try {
  111.           /*  final HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
  112.             hashMap.put("user", s);
  113.             hashMap.put("password", (Integer)s2);
  114.             hashMap.put("version", 13);
  115.             final String executePost = Util.executePost("https://login.minecraft.net/", (Map<String, Object>)hashMap);
  116.             if (executePost == null) {
  117.                 this.showError("Can't connect to minecraft.net");
  118.                 this.loginForm.setNoNetwork(false);
  119.                 return;
  120.             }
  121.             if (!executePost.contains(":")) {
  122.                 boolean noNetwork = false;
  123.                 if (executePost.trim().equals("Bad login")) {
  124.                     this.showError("Login failed");
  125.                 }
  126.                 else if (executePost.trim().equals("Old version")) {
  127.                     this.loginForm.setOutdated();
  128.                     this.showError("Outdated launcher");
  129.                 }
  130.                 else if (executePost.trim().equals("User not premium")) {
  131.                     this.showError(executePost);
  132.                     noNetwork = true;
  133.                 }
  134.                 else {
  135.                     this.showError(executePost);
  136.                 }
  137.                 this.loginForm.setNoNetwork(noNetwork);
  138.                 return;
  139.             }
  140.             final String[] split = executePost.split(":");
  141.             this.launcher = new Launcher();
  142.             this.launcher.customParameters.putAll(this.customParameters);
  143.             this.launcher.customParameters.put("userName", split[2].trim());
  144.             this.launcher.customParameters.put("latestVersion", split[0].trim());
  145.             this.launcher.customParameters.put("downloadTicket", split[1].trim());
  146.             this.launcher.customParameters.put("sessionId", split[3].trim());
  147.             this.launcher.init();
  148.             this.removeAll();
  149.             this.add(this.launcher, "Center");
  150.             this.validate();
  151.             this.launcher.start();
  152.             this.loginForm.loginOk();
  153.             this.loginForm = null;
  154.             this.setTitle("Minecraft");
  155.         }
  156.         catch (Exception ex) {
  157.             ex.printStackTrace();
  158.             this.showError(ex.toString());
  159.             this.loginForm.setNoNetwork(false);
  160.         }*/
  161.            
  162.  
  163.            
  164.            
  165.              System.setProperty("java.net.preferIPv4Stack", "true");
  166.              final OptionParser optionParser = new OptionParser();
  167.              optionParser.allowsUnrecognizedOptions();
  168.              optionParser.accepts("help", "Show help").forHelp();
  169.              final OptionSpec<String> proxyHostOption = optionParser.accepts("proxyHost", "Optional").withRequiredArg();
  170.              final OptionSpec<Integer> proxyPortOption = optionParser.accepts("proxyPort", "Optional").withRequiredArg().defaultsTo("8080", new String[0]).ofType(Integer.class);
  171.              final OptionSpec<String> proxyUserOption = optionParser.accepts("proxyUser", "Optional").withRequiredArg();
  172.              final OptionSpec<String> proxyPassOption = optionParser.accepts("proxyPass", "Optional").withRequiredArg();
  173.              final OptionSpec<File> workingDirectoryOption = optionParser.accepts("workDir", "Optional").withRequiredArg().ofType(File.class).defaultsTo(Util.getWorkingDirectory(), new File[0]);
  174.              final OptionSpec<String> nonOptions = optionParser.nonOptions();
  175.              OptionSet optionSet;
  176.              try {
  177.                  optionSet = optionParser.parse("--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userProperties ${user_properties} --userType ${user_type}");
  178.                  
  179.              }
  180.              catch(final OptionException e) {
  181.                  optionParser.printHelpOn(System.out);
  182.                  System.out.println("(to pass in arguments to minecraft directly use: '--' followed by your arguments");
  183.                  return;
  184.              }
  185.              if(optionSet.has("help")) {
  186.                  optionParser.printHelpOn(System.out);
  187.                  return;
  188.              }
  189.              final String hostName = optionSet.valueOf(proxyHostOption);
  190.              Proxy proxy = Proxy.NO_PROXY;
  191.              if(hostName != null)
  192.                  try {
  193.                      proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(hostName, optionSet.valueOf(proxyPortOption).intValue()));
  194.                  }
  195.                  catch(final Exception ignored) {
  196.                  }
  197.              final String proxyUser = optionSet.valueOf(proxyUserOption);
  198.              final String proxyPass = optionSet.valueOf(proxyPassOption);
  199.              PasswordAuthentication passwordAuthentication = null;
  200.             // if(!proxy.equals(Proxy.NO_PROXY) && stringHasValue(proxyUser) && stringHasValue(proxyPass)) {
  201.                  passwordAuthentication = new PasswordAuthentication(proxyUser, proxyPass.toCharArray());
  202.                  final PasswordAuthentication auth = passwordAuthentication;
  203.                  Authenticator.setDefault(new Authenticator() {
  204.                      @Override
  205.                      protected PasswordAuthentication getPasswordAuthentication() {
  206.                           launcher = new Launcher();
  207.                            launcher.customParameters.putAll(customParameters);
  208.                            launcher.customParameters.put("userName", auth.getUserName());
  209.                          launcher.customParameters.put("latestVersion", "true");
  210.                           System.out.println(auth.getPassword());
  211.                             launcher.init();
  212.                            removeAll();
  213.                             add(launcher, "Center");
  214.                            validate();
  215.                             launcher.start();
  216.                             loginForm.loginOk();
  217.                             loginForm = null;
  218.                             setTitle("Minecraft");
  219.  
  220.                          return auth;
  221.                      }
  222.                  //});
  223.              });}catch(Exception e) {
  224.                  e.printStackTrace();
  225.              }
  226.        
  227.            
  228.     }
  229.        
  230.         public static boolean stringHasValue(String string)
  231.         {
  232.           return (string != null) && (!string.isEmpty());
  233.         }
  234.    
  235.     private void showError(final String error) {
  236.         this.removeAll();
  237.         this.add(this.loginForm);
  238.         this.loginForm.setError(error);
  239.         this.validate();
  240.     }
  241.    
  242.     public boolean canPlayOffline(final String s) {
  243.         final Launcher launcher = new Launcher();
  244.         launcher.customParameters.putAll(this.customParameters);
  245.         launcher.init(s, null, null, "1");
  246.         return launcher.canPlayOffline();
  247.     }
  248.    
  249.     public static void main(final String[] array) {
  250.         try {
  251.             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  252.         }
  253.         catch (Exception ex) {}
  254.         System.out.println("asdf");
  255.         System.setProperty("java.net.preferIPv4Stack", "true");
  256.         System.setProperty("java.net.preferIPv6Addresses", "false");
  257.         final LauncherFrame launcherFrame = new LauncherFrame();
  258.         launcherFrame.setVisible(true);
  259.         launcherFrame.customParameters.put("stand-alone", "true");
  260.         for (final String s : array) {
  261.             if (s.startsWith("-u=") || s.startsWith("--user=")) {
  262.                 final String argValue = getArgValue(s);
  263.                 launcherFrame.customParameters.put("username", argValue);
  264.                 launcherFrame.loginForm.userName.setText(argValue);
  265.             }
  266.             else if (s.startsWith("-p=") || s.startsWith("--password=")) {
  267.                 final String argValue2 = getArgValue(s);
  268.                 launcherFrame.customParameters.put("password", argValue2);
  269.                 launcherFrame.loginForm.password.setText(argValue2);
  270.             }
  271.             else if (s.startsWith("--noupdate")) {
  272.                 launcherFrame.customParameters.put("noupdate", "true");
  273.             }
  274.         }
  275.         if (array.length >= 3) {
  276.             String s2 = array[2];
  277.             String s3 = "25565";
  278.             if (s2.contains(":")) {
  279.                 final String[] split = s2.split(":");
  280.                 s2 = split[0];
  281.                 s3 = split[1];
  282.             }
  283.             launcherFrame.customParameters.put("server", s2);
  284.             launcherFrame.customParameters.put("port", s3);
  285.         }
  286.     }
  287.    
  288.     private static String getArgValue(final String s) {
  289.         final int index = s.indexOf(61);
  290.         if (index < 0) {
  291.             return "";
  292.         }
  293.         return s.substring(index + 1);
  294.     }
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement