use of net.minecraft.util.Session in project malmo by Microsoft.
the class AuthenticationHelper method setPlayerName.
public static boolean setPlayerName(Session currentSession, String newPlayerName) {
if (currentSession.getUsername().equals(newPlayerName))
return true;
// Create new session object:
Session newSession = new Session(newPlayerName, currentSession.getPlayerID(), currentSession.getToken(), "mojang");
// Prevents calls to the session service to get profile properties
newSession.setProperties(new com.mojang.authlib.properties.PropertyMap());
return setSession(newSession);
}
use of net.minecraft.util.Session in project Wurst-MC-1.12 by Wurst-Imperium.
the class LoginManager method login.
public static String login(String email, String password) {
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "").createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(email);
auth.setPassword(password);
try {
auth.logIn();
Minecraft.getMinecraft().session = new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
return "";
} catch (AuthenticationUnavailableException e) {
return "�4�lCannot contact authentication server!";
} catch (AuthenticationException e) {
e.printStackTrace();
if (e.getMessage().contains("Invalid username or password.") || e.getMessage().toLowerCase().contains("account migrated"))
return "�4�lWrong password!";
else
return "�4�lCannot contact authentication server!";
} catch (NullPointerException e) {
return "�4�lWrong password!";
}
}
Aggregations