diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccountFactory.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccountFactory.java index 69c01df30..621973e9d 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccountFactory.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorAccountFactory.java @@ -23,8 +23,11 @@ import org.jackhuang.hmcl.auth.CharacterSelector; import org.jackhuang.hmcl.auth.yggdrasil.CompleteGameProfile; import org.jackhuang.hmcl.auth.yggdrasil.GameProfile; import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilSession; +import org.jackhuang.hmcl.util.javafx.ObservableOptionalCache; + import java.util.Map; import java.util.Objects; +import java.util.UUID; import java.util.function.Function; import static org.jackhuang.hmcl.util.Lang.tryCast; @@ -70,7 +73,9 @@ public class AuthlibInjectorAccountFactory extends AccountFactory properties = it; GameProfile selected = session.getSelectedProfile(); - server.getYggdrasilService().getProfileRepository().put(selected.getId(), new CompleteGameProfile(selected, properties)); + ObservableOptionalCache profileRepository = server.getYggdrasilService().getProfileRepository(); + profileRepository.put(selected.getId(), new CompleteGameProfile(selected, properties)); + profileRepository.invalidate(selected.getId()); }); return new AuthlibInjectorAccount(server, downloader, username, session); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccountFactory.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccountFactory.java index 19b7a9a10..0260edd82 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccountFactory.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccountFactory.java @@ -20,9 +20,11 @@ package org.jackhuang.hmcl.auth.yggdrasil; import org.jackhuang.hmcl.auth.AccountFactory; import org.jackhuang.hmcl.auth.AuthenticationException; import org.jackhuang.hmcl.auth.CharacterSelector; +import org.jackhuang.hmcl.util.javafx.ObservableOptionalCache; import java.util.Map; import java.util.Objects; +import java.util.UUID; import static org.jackhuang.hmcl.util.Lang.tryCast; @@ -63,7 +65,9 @@ public class YggdrasilAccountFactory extends AccountFactory { @SuppressWarnings("unchecked") Map properties = it; GameProfile selected = session.getSelectedProfile(); - service.getProfileRepository().put(selected.getId(), new CompleteGameProfile(selected, properties)); + ObservableOptionalCache profileRepository = service.getProfileRepository(); + profileRepository.put(selected.getId(), new CompleteGameProfile(selected, properties)); + profileRepository.invalidate(selected.getId()); }); return new YggdrasilAccount(service, username, session);