Search in sources :

Example 6 with MojangUser

use of net.technicpack.minecraftcore.mojang.auth.MojangUser in project LauncherV3 by TechnicPack.

the class LoginFrame method refreshUsers.

protected void refreshUsers() {
    Collection<MojangUser> mojangUserAccounts = userModel.getUsers();
    MojangUser lastMojangUser = userModel.getLastUser();
    if (mojangUserAccounts.size() == 0) {
        name.setVisible(true);
        nameSelect.setVisible(false);
        clearCurrentUser();
    } else {
        name.setVisible(false);
        nameSelect.setVisible(true);
        nameSelect.removeAllItems();
        for (MojangUser account : mojangUserAccounts) {
            nameSelect.addItem(account);
        }
        nameSelect.addItem(null);
        if (lastMojangUser == null)
            lastMojangUser = mojangUserAccounts.iterator().next();
        setCurrentUser(lastMojangUser);
    }
}
Also used : MojangUser(net.technicpack.minecraftcore.mojang.auth.MojangUser)

Example 7 with MojangUser

use of net.technicpack.minecraftcore.mojang.auth.MojangUser 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)

Example 8 with MojangUser

use of net.technicpack.minecraftcore.mojang.auth.MojangUser in project LauncherV3 by TechnicPack.

the class TechnicUserStore method addUser.

public void addUser(IUserType user) {
    if (savedUsers.containsKey(user.getUsername())) {
        IUserType oldUser = savedUsers.get(user.getUsername());
        if (oldUser instanceof MojangUser && user instanceof MojangUser) {
            ((MojangUser) user).mergeUserProperties((MojangUser) oldUser);
        }
    }
    savedUsers.put(user.getUsername(), user);
    save();
}
Also used : IUserType(net.technicpack.launchercore.auth.IUserType) MojangUser(net.technicpack.minecraftcore.mojang.auth.MojangUser)

Aggregations

MojangUser (net.technicpack.minecraftcore.mojang.auth.MojangUser)8 UserModel (net.technicpack.launchercore.auth.UserModel)3 File (java.io.File)2 IUserType (net.technicpack.launchercore.auth.IUserType)2 MirrorStore (net.technicpack.launchercore.mirror.MirrorStore)2 JsonWebSecureMirror (net.technicpack.launchercore.mirror.secure.rest.JsonWebSecureMirror)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 CacheDiscordApi (net.technicpack.discord.CacheDiscordApi)1 HttpDiscordApi (net.technicpack.discord.HttpDiscordApi)1 IDiscordApi (net.technicpack.discord.IDiscordApi)1 Installer (net.technicpack.launcher.launch.Installer)1 IMigrator (net.technicpack.launcher.settings.migration.IMigrator)1 InitialV3Migrator (net.technicpack.launcher.settings.migration.InitialV3Migrator)1 LauncherFrame (net.technicpack.launcher.ui.LauncherFrame)1 LoginFrame (net.technicpack.launcher.ui.LoginFrame)1