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);
}
}
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());
}
}
}
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();
}
Aggregations