fix(login): prompt to retry logging in. Closes #1658 #1591 #1544 1608.

This commit is contained in:
huanghongxun
2022-08-28 23:57:47 +08:00
parent 0c172e5d08
commit 08d7ff138b
13 changed files with 109 additions and 47 deletions

View File

@@ -64,7 +64,7 @@ public abstract class Account implements Observable {
* Play offline.
* @return the specific offline player's info.
*/
public abstract Optional<AuthInfo> playOffline() throws AuthenticationException;
public abstract AuthInfo playOffline() throws AuthenticationException;
public abstract Map<Object, Object> toStorage();

View File

@@ -0,0 +1,21 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.auth;
public class NotLoggedInException extends AuthenticationException {
}

View File

@@ -17,10 +17,7 @@
*/
package org.jackhuang.hmcl.auth.authlibinjector;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.auth.AuthenticationException;
import org.jackhuang.hmcl.auth.CharacterSelector;
import org.jackhuang.hmcl.auth.ServerDisconnectException;
import org.jackhuang.hmcl.auth.*;
import org.jackhuang.hmcl.auth.yggdrasil.CompleteGameProfile;
import org.jackhuang.hmcl.auth.yggdrasil.TextureType;
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
@@ -66,15 +63,15 @@ public class AuthlibInjectorAccount extends YggdrasilAccount {
}
@Override
public Optional<AuthInfo> playOffline() {
Optional<AuthInfo> auth = super.playOffline();
public AuthInfo playOffline() throws AuthenticationException {
AuthInfo auth = super.playOffline();
Optional<AuthlibInjectorArtifactInfo> artifact = downloader.getArtifactInfoImmediately();
Optional<String> prefetchedMeta = server.getMetadataResponse();
if (auth.isPresent() && artifact.isPresent() && prefetchedMeta.isPresent()) {
return Optional.of(new AuthlibInjectorAuthInfo(auth.get(), artifact.get(), server, prefetchedMeta.get()));
if (artifact.isPresent() && prefetchedMeta.isPresent()) {
return new AuthlibInjectorAuthInfo(auth, artifact.get(), server, prefetchedMeta.get());
} else {
return Optional.empty();
throw new NotLoggedInException();
}
}

View File

@@ -117,8 +117,8 @@ public class MicrosoftAccount extends OAuthAccount {
}
@Override
public Optional<AuthInfo> playOffline() {
return Optional.of(session.toAuthInfo());
public AuthInfo playOffline() {
return session.toAuthInfo();
}
@Override

View File

@@ -180,8 +180,8 @@ public class OfflineAccount extends Account {
}
@Override
public Optional<AuthInfo> playOffline() throws AuthenticationException {
return Optional.of(logIn());
public AuthInfo playOffline() throws AuthenticationException {
return logIn();
}
@Override

View File

@@ -161,8 +161,8 @@ public class YggdrasilAccount extends ClassicAccount {
}
@Override
public Optional<AuthInfo> playOffline() {
return Optional.of(session.toAuthInfo());
public AuthInfo playOffline() throws AuthenticationException {
return session.toAuthInfo();
}
@Override