Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
2,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1.  
  2. package me.lordethan.cryton.utils;
  3.  
  4. import com.mojang.authlib.Agent;
  5. import com.mojang.authlib.GameProfile;
  6. import com.mojang.authlib.UserAuthentication;
  7. import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
  8. import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
  9. import java.net.Proxy;
  10. import java.util.UUID;
  11. import me.lordethan.cryton.utils.ChatColor;
  12. import net.minecraft.client.Minecraft;
  13. import net.minecraft.util.Session;
  14.  
  15. public class LoginThread
  16. extends Thread {
  17. private final Minecraft mc = Minecraft.getMinecraft();
  18. private String status;
  19. private final String username;
  20. private final String password;
  21.  
  22. public LoginThread(String username, String password) {
  23. super("Login Thread");
  24. this.username = username;
  25. this.password = password;
  26. this.status = "Current Account :" + this.username;
  27. }
  28.  
  29. private final Session createSession(String username, String password) {
  30. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  31. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
  32. auth.setUsername(username);
  33. auth.setPassword(password);
  34. try {
  35. auth.logIn();
  36. return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
  37. }
  38. catch (Exception e) {
  39. return null;
  40. }
  41. }
  42.  
  43. public String getStatus() {
  44. return this.status;
  45. }
  46.  
  47. @Override
  48. public void run() {
  49. if (this.password.equals("")) {
  50. this.mc.session = new Session(this.username, "", "", "mojang");
  51. this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. " + this.username + " - cracked";
  52. return;
  53. }
  54. this.status = (Object)((Object)ChatColor.YELLOW) + "Logging in";
  55. Session auth = this.createSession(this.username, this.password);
  56. if (auth == null) {
  57. this.status = (Object)((Object)ChatColor.RED) + "Login failed";
  58. } else {
  59. this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. (" + auth.getUsername() + ")";
  60. this.mc.session = auth;
  61. }
  62. }
  63.  
  64. public void setStatus(String status) {
  65. this.status = status;
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement