mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-12 14:14:52 +08:00
* close #1980: Make LittleSkin optional * update * update * update
This commit is contained in:
parent
42dd877b97
commit
0ec00ede70
@ -85,7 +85,6 @@ public final class Accounts {
|
|||||||
public static final YggdrasilAccountFactory FACTORY_MOJANG = YggdrasilAccountFactory.MOJANG;
|
public static final YggdrasilAccountFactory FACTORY_MOJANG = YggdrasilAccountFactory.MOJANG;
|
||||||
public static final AuthlibInjectorAccountFactory FACTORY_AUTHLIB_INJECTOR = new AuthlibInjectorAccountFactory(AUTHLIB_INJECTOR_DOWNLOADER, Accounts::getOrCreateAuthlibInjectorServer);
|
public static final AuthlibInjectorAccountFactory FACTORY_AUTHLIB_INJECTOR = new AuthlibInjectorAccountFactory(AUTHLIB_INJECTOR_DOWNLOADER, Accounts::getOrCreateAuthlibInjectorServer);
|
||||||
public static final MicrosoftAccountFactory FACTORY_MICROSOFT = new MicrosoftAccountFactory(new MicrosoftService(OAUTH_CALLBACK));
|
public static final MicrosoftAccountFactory FACTORY_MICROSOFT = new MicrosoftAccountFactory(new MicrosoftService(OAUTH_CALLBACK));
|
||||||
public static final BoundAuthlibInjectorAccountFactory FACTORY_LITTLE_SKIN = getAccountFactoryByAuthlibInjectorServer(new AuthlibInjectorServer("https://littleskin.cn/api/yggdrasil/"));
|
|
||||||
public static final List<AccountFactory<?>> FACTORIES = immutableListOf(FACTORY_OFFLINE, FACTORY_MOJANG, FACTORY_MICROSOFT, FACTORY_AUTHLIB_INJECTOR);
|
public static final List<AccountFactory<?>> FACTORIES = immutableListOf(FACTORY_OFFLINE, FACTORY_MOJANG, FACTORY_MICROSOFT, FACTORY_AUTHLIB_INJECTOR);
|
||||||
|
|
||||||
// ==== login type / account factory mapping ====
|
// ==== login type / account factory mapping ====
|
||||||
@ -227,6 +226,16 @@ public final class Accounts {
|
|||||||
if (initialized)
|
if (initialized)
|
||||||
throw new IllegalStateException("Already initialized");
|
throw new IllegalStateException("Already initialized");
|
||||||
|
|
||||||
|
if (!config().isAddedLittleSkin()) {
|
||||||
|
AuthlibInjectorServer littleSkin = new AuthlibInjectorServer("https://littleskin.cn/api/yggdrasil/");
|
||||||
|
|
||||||
|
if (config().getAuthlibInjectorServers().stream().noneMatch(it -> littleSkin.getUrl().equals(it.getUrl()))) {
|
||||||
|
config().getAuthlibInjectorServers().add(0, littleSkin);
|
||||||
|
}
|
||||||
|
|
||||||
|
config().setAddedLittleSkin(true);
|
||||||
|
}
|
||||||
|
|
||||||
loadGlobalAccountStorages();
|
loadGlobalAccountStorages();
|
||||||
|
|
||||||
// load accounts
|
// load accounts
|
||||||
@ -324,14 +333,6 @@ public final class Accounts {
|
|||||||
|
|
||||||
triggerAuthlibInjectorUpdateCheck();
|
triggerAuthlibInjectorUpdateCheck();
|
||||||
|
|
||||||
Schedulers.io().execute(() -> {
|
|
||||||
try {
|
|
||||||
FACTORY_LITTLE_SKIN.getServer().fetchMetadataResponse();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Failed to fetch authlib-injector server metdata: " + FACTORY_LITTLE_SKIN.getServer(), e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (AuthlibInjectorServer server : config().getAuthlibInjectorServers()) {
|
for (AuthlibInjectorServer server : config().getAuthlibInjectorServers()) {
|
||||||
if (selected instanceof AuthlibInjectorAccount && ((AuthlibInjectorAccount) selected).getServer() == server)
|
if (selected instanceof AuthlibInjectorAccount && ((AuthlibInjectorAccount) selected).getServer() == server)
|
||||||
continue;
|
continue;
|
||||||
@ -385,10 +386,6 @@ public final class Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static AuthlibInjectorServer getOrCreateAuthlibInjectorServer(String url) {
|
private static AuthlibInjectorServer getOrCreateAuthlibInjectorServer(String url) {
|
||||||
if (url.equals(FACTORY_LITTLE_SKIN.getServer().getUrl())) {
|
|
||||||
return FACTORY_LITTLE_SKIN.getServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
return config().getAuthlibInjectorServers().stream()
|
return config().getAuthlibInjectorServers().stream()
|
||||||
.filter(server -> url.equals(server.getUrl()))
|
.filter(server -> url.equals(server.getUrl()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
@ -166,6 +166,9 @@ public final class Config implements Cloneable, Observable {
|
|||||||
@SerializedName("authlibInjectorServers")
|
@SerializedName("authlibInjectorServers")
|
||||||
private ObservableList<AuthlibInjectorServer> authlibInjectorServers = FXCollections.observableArrayList(server -> new Observable[] { server });
|
private ObservableList<AuthlibInjectorServer> authlibInjectorServers = FXCollections.observableArrayList(server -> new Observable[] { server });
|
||||||
|
|
||||||
|
@SerializedName("addedLittleSkin")
|
||||||
|
private BooleanProperty addedLittleSkin = new SimpleBooleanProperty(false);
|
||||||
|
|
||||||
@SerializedName("promptedVersion")
|
@SerializedName("promptedVersion")
|
||||||
private StringProperty promptedVersion = new SimpleStringProperty();
|
private StringProperty promptedVersion = new SimpleStringProperty();
|
||||||
|
|
||||||
@ -550,6 +553,18 @@ public final class Config implements Cloneable, Observable {
|
|||||||
return authlibInjectorServers;
|
return authlibInjectorServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAddedLittleSkin() {
|
||||||
|
return addedLittleSkin.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanProperty addedLittleSkinProperty() {
|
||||||
|
return addedLittleSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddedLittleSkin(boolean addedLittleSkin) {
|
||||||
|
this.addedLittleSkin.set(addedLittleSkin);
|
||||||
|
}
|
||||||
|
|
||||||
public int getConfigVersion() {
|
public int getConfigVersion() {
|
||||||
return configVersion.get();
|
return configVersion.get();
|
||||||
}
|
}
|
||||||
|
@ -124,14 +124,6 @@ public class AccountListPage extends DecoratorAnimatedPage implements DecoratorP
|
|||||||
microsoftItem.setOnAction(e -> Controllers.dialog(new CreateAccountPane(Accounts.FACTORY_MICROSOFT)));
|
microsoftItem.setOnAction(e -> Controllers.dialog(new CreateAccountPane(Accounts.FACTORY_MICROSOFT)));
|
||||||
boxMethods.getChildren().add(microsoftItem);
|
boxMethods.getChildren().add(microsoftItem);
|
||||||
|
|
||||||
AdvancedListItem littleSkinItem = new AdvancedListItem();
|
|
||||||
littleSkinItem.getStyleClass().add("navigation-drawer-item");
|
|
||||||
littleSkinItem.setActionButtonVisible(false);
|
|
||||||
littleSkinItem.setTitle(i18n("account.methods.little_skin"));
|
|
||||||
littleSkinItem.setLeftGraphic(wrap(SVG::server));
|
|
||||||
littleSkinItem.setOnAction(e -> Controllers.dialog(new CreateAccountPane(Accounts.FACTORY_LITTLE_SKIN)));
|
|
||||||
boxMethods.getChildren().add(littleSkinItem);
|
|
||||||
|
|
||||||
VBox boxAuthServers = new VBox();
|
VBox boxAuthServers = new VBox();
|
||||||
authServerItems = MappedObservableList.create(skinnable.authServersProperty(), server -> {
|
authServerItems = MappedObservableList.create(skinnable.authServersProperty(), server -> {
|
||||||
AdvancedListItem item = new AdvancedListItem();
|
AdvancedListItem item = new AdvancedListItem();
|
||||||
|
Loading…
Reference in New Issue
Block a user