Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. package me.cheese.faurax.login;
  2.  
  3. import net.minecraft.client.*;
  4. import net.minecraft.util.*;
  5. import java.net.*;
  6. import com.mojang.authlib.yggdrasil.*;
  7. import com.mojang.authlib.*;
  8. import com.mojang.authlib.exceptions.*;
  9.  
  10. public class Login
  11. {
  12. public Login(final String name, final String password, final boolean online) {
  13. if (online) {
  14. if (name != null && password != null) {
  15. new Thread() {
  16. @Override
  17. public void run() {
  18. Login.loginPassword(name, password);
  19. }
  20. }.start();
  21. }
  22. else {
  23. System.out.println("Username and/or password is incorect.");
  24. }
  25. }
  26. else {
  27. loginPasswordOffline(name);
  28. }
  29. }
  30.  
  31. public static void loginPasswordOffline(final String username) {
  32. Minecraft.getMinecraft().session = new Session(username, username, username, "MOJANG");
  33. }
  34.  
  35. public static String loginPassword(final String username, final String password) {
  36. if (username == null || username.length() < 0 || password == null || password.length() <= 0) {
  37. return null;
  38. }
  39. final YggdrasilAuthenticationService a = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  40. final YggdrasilUserAuthentication b = (YggdrasilUserAuthentication)a.createUserAuthentication(Agent.MINECRAFT);
  41. b.setUsername(username);
  42. b.setPassword(password);
  43. try {
  44. b.logIn();
  45. Minecraft.getMinecraft().session = new Session(b.getSelectedProfile().getName(), b.getSelectedProfile().getId().toString(), b.getAuthenticatedToken(), "MOJANG");
  46. }
  47. catch (AuthenticationException e) {
  48. e.printStackTrace();
  49. }
  50. return null;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement