Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. package me.marcigamer.legitclient.ui;
  2.  
  3. import java.net.Proxy;
  4.  
  5. import com.mojang.authlib.Agent;
  6. import com.mojang.authlib.exceptions.AuthenticationException;
  7. import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
  8. import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
  9.  
  10. import net.minecraft.client.Minecraft;
  11. import net.minecraft.util.Session;
  12.  
  13. public class AltThread extends Thread {
  14.  
  15. protected final Minecraft mc = Minecraft.getMinecraft();
  16. protected final String password;
  17. protected String status;
  18. protected final String username;
  19.  
  20. public AltThread(String username, String password) {
  21. super("Alt Thread");
  22. this.username = username;
  23. this.password = password;
  24. this.status = "§7Waiting...";
  25. }
  26.  
  27. public void setStatus(String status) {
  28. this.status = status;
  29. }
  30.  
  31. public String getStatus() {
  32. return this.status;
  33. }
  34.  
  35. protected final Session createSession(String username, String password) {
  36. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  37. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
  38. .createUserAuthentication(Agent.MINECRAFT);
  39. auth.setUsername(username);
  40. auth.setPassword(password);
  41. try {
  42. auth.logIn();
  43. return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(),
  44. auth.getAuthenticatedToken(), "mojang");
  45. } catch (AuthenticationException e) {
  46. }
  47. return null;
  48. }
  49.  
  50. public final String checkAndAddAlt(String username, String password) {
  51. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  52. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
  53. .createUserAuthentication(Agent.MINECRAFT);
  54. auth.setUsername(username);
  55. auth.setPassword(password);
  56. try {
  57. auth.logIn();
  58. return (status = "§aAlt added. (" + username + ")");
  59. } catch (AuthenticationException e) {
  60. e.printStackTrace();
  61. return (status = "§cAlt failed! (" + username + ")");
  62. }
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement