Search in sources :

Example 1 with Session

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);
}
Also used : Session(net.minecraft.util.Session)

Example 2 with Session

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!";
    }
}
Also used : AuthenticationUnavailableException(com.mojang.authlib.exceptions.AuthenticationUnavailableException) AuthenticationException(com.mojang.authlib.exceptions.AuthenticationException) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) YggdrasilUserAuthentication(com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication) Session(net.minecraft.util.Session)

Aggregations

Session (net.minecraft.util.Session)2 AuthenticationException (com.mojang.authlib.exceptions.AuthenticationException)1 AuthenticationUnavailableException (com.mojang.authlib.exceptions.AuthenticationUnavailableException)1 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)1 YggdrasilUserAuthentication (com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication)1