Search in sources :

Example 1 with AuthenticationNetworkFailureException

use of net.technicpack.launchercore.exception.AuthenticationNetworkFailureException in project LauncherV3 by TechnicPack.

the class LoginFrame method verifyExistingLogin.

private void verifyExistingLogin(MojangUser mojangUser) {
    MojangUser loginMojangUser = mojangUser;
    boolean rejected = false;
    try {
        UserModel.AuthError error = userModel.attemptUserRefresh(mojangUser);
        if (error != null) {
            JOptionPane.showMessageDialog(this, error.getErrorDescription(), error.getError(), JOptionPane.ERROR_MESSAGE);
            loginMojangUser = null;
            rejected = true;
        }
    } catch (AuthenticationNetworkFailureException ex) {
        Utils.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
        // is actually at the login UI clicking the login button), give them a choice.
        if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, "The auth servers at Minecraft.net are inaccessible.  Would you like to play offline?", "Offline Play", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE)) {
            // This is the last time we'll have access to the user's real username, so we should set the last-used
            // username now
            userModel.setLastUser(mojangUser);
            // Create offline user
            loginMojangUser = new MojangUser(mojangUser.getDisplayName());
        } else {
            // Use clicked 'no', so just pull the ripcord and get back to the UI
            loginMojangUser = null;
        }
    }
    if (loginMojangUser == null) {
        // and refresh the user list
        if (rejected) {
            userModel.removeUser(mojangUser);
            refreshUsers();
            setCurrentUser(mojangUser.getUsername());
        }
    }
}
Also used : UserModel(net.technicpack.launchercore.auth.UserModel) MojangUser(net.technicpack.minecraftcore.mojang.auth.MojangUser) AuthenticationNetworkFailureException(net.technicpack.launchercore.exception.AuthenticationNetworkFailureException)

Aggregations

UserModel (net.technicpack.launchercore.auth.UserModel)1 AuthenticationNetworkFailureException (net.technicpack.launchercore.exception.AuthenticationNetworkFailureException)1 MojangUser (net.technicpack.minecraftcore.mojang.auth.MojangUser)1