Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
2,606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. package mc.sebakagrief.ru.util;
  2.  
  3. import com.mojang.authlib.Agent;
  4. import com.mojang.authlib.GameProfile;
  5. import com.mojang.authlib.exceptions.AuthenticationException;
  6. import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
  7. import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
  8. import java.net.Proxy;
  9. import java.util.UUID;
  10. import net.minecraft.client.Minecraft;
  11. import net.minecraft.util.Session;
  12.  
  13. public class AltThread extends Thread {
  14. private final Minecraft mc = Minecraft.getMinecraft();
  15. private final String password;
  16. private final String username;
  17.  
  18. public AltThread(String username, String password) {
  19. super("Alt Login Thread");
  20. this.username = username;
  21. this.password = password;
  22. }
  23.  
  24. private final Session createSession(String username, String password) {
  25. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  26. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
  27. .createUserAuthentication(Agent.MINECRAFT);
  28. auth.setUsername(username);
  29. auth.setPassword(password);
  30. try {
  31. auth.logIn();
  32. return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(),
  33. auth.getAuthenticatedToken(), "mojang");
  34. } catch (AuthenticationException e) {
  35. }
  36. return null;
  37. }
  38.  
  39. public void run() {
  40. if (this.password.equals("")) {
  41. this.mc.session = new Session(this.username, mc.session.getPlayerID(), mc.session.getSessionID(), "mojang");
  42. return;
  43. }
  44. Session auth = createSession(this.username, this.password);
  45. if (auth == null) {
  46. } else {
  47. this.mc.session = auth;
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement