mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-12 13:26:53 -04:00
Fix IllegalArgumentException: Invalid UUID String
This commit is contained in:
parent
dbfcf1facc
commit
e8cf9644eb
@ -20,10 +20,7 @@ package org.jackhuang.hmcl.auth.offline;
|
||||
import org.jackhuang.hmcl.auth.Account;
|
||||
import org.jackhuang.hmcl.auth.AuthInfo;
|
||||
import org.jackhuang.hmcl.auth.AuthenticationException;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.Pair;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
|
||||
import org.jackhuang.hmcl.util.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -66,7 +63,7 @@ public class OfflineAccount extends Account {
|
||||
|
||||
@Override
|
||||
public AuthInfo logIn() throws AuthenticationException {
|
||||
if (StringUtils.isBlank(username) || StringUtils.isBlank(uuid))
|
||||
if (StringUtils.isBlank(username))
|
||||
throw new AuthenticationException("Username cannot be empty");
|
||||
|
||||
return new AuthInfo(username, uuid, uuid);
|
||||
@ -107,6 +104,9 @@ public class OfflineAccount extends Account {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OfflineAccount[username=" + username + ", uuid=" + uuid + "]";
|
||||
return new ToStringBuilder(this)
|
||||
.append("username", username)
|
||||
.append("uuid", uuid)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,13 @@ import org.jackhuang.hmcl.auth.AccountFactory;
|
||||
import org.jackhuang.hmcl.auth.CharacterSelector;
|
||||
import org.jackhuang.hmcl.util.DigestUtils;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.Logging;
|
||||
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -46,6 +50,9 @@ public class OfflineAccountFactory extends AccountFactory<OfflineAccount> {
|
||||
.orElseThrow(() -> new IllegalStateException("Offline account configuration malformed."));
|
||||
String uuid = Lang.get(storage, "uuid", String.class)
|
||||
.orElse(getUUIDFromUserName(username));
|
||||
|
||||
// Check if the uuid is vaild
|
||||
UUIDTypeAdapter.fromString(uuid);
|
||||
|
||||
return new OfflineAccount(username, uuid);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user