mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-15 14:56:05 -04:00
Rename fields in Accounts
This commit is contained in:
parent
be8cd13b08
commit
c38848ea0e
@ -50,23 +50,23 @@ public final class Accounts {
|
|||||||
new AuthlibInjectorDownloader(Launcher.HMCL_DIRECTORY.toPath(), () -> Settings.INSTANCE.getDownloadProvider())::getArtifactInfo,
|
new AuthlibInjectorDownloader(Launcher.HMCL_DIRECTORY.toPath(), () -> Settings.INSTANCE.getDownloadProvider())::getArtifactInfo,
|
||||||
Accounts::getOrCreateAuthlibInjectorServer);
|
Accounts::getOrCreateAuthlibInjectorServer);
|
||||||
|
|
||||||
public static final String OFFLINE_ACCOUNT_KEY = "offline";
|
private static final String TYPE_OFFLINE = "offline";
|
||||||
public static final String YGGDRASIL_ACCOUNT_KEY = "yggdrasil";
|
private static final String TYPE_YGGDRASIL_ACCOUNT = "yggdrasil";
|
||||||
public static final String AUTHLIB_INJECTOR_ACCOUNT_KEY = "authlibInjector";
|
private static final String TYPE_AUTHLIB_INJECTOR = "authlibInjector";
|
||||||
|
|
||||||
public static final Map<String, AccountFactory<?>> ACCOUNT_FACTORY = mapOf(
|
static final Map<String, AccountFactory<?>> TYPE_TO_ACCOUNT_FACTORY = mapOf(
|
||||||
pair(OFFLINE_ACCOUNT_KEY, FACTORY_OFFLINE),
|
pair(TYPE_OFFLINE, FACTORY_OFFLINE),
|
||||||
pair(YGGDRASIL_ACCOUNT_KEY, FACTORY_YGGDRASIL),
|
pair(TYPE_YGGDRASIL_ACCOUNT, FACTORY_YGGDRASIL),
|
||||||
pair(AUTHLIB_INJECTOR_ACCOUNT_KEY, FACTORY_AUTHLIB_INJECTOR)
|
pair(TYPE_AUTHLIB_INJECTOR, FACTORY_AUTHLIB_INJECTOR)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static String getAccountType(Account account) {
|
static String getAccountType(Account account) {
|
||||||
if (account instanceof OfflineAccount)
|
if (account instanceof OfflineAccount)
|
||||||
return OFFLINE_ACCOUNT_KEY;
|
return TYPE_OFFLINE;
|
||||||
else if (account instanceof AuthlibInjectorAccount)
|
else if (account instanceof AuthlibInjectorAccount)
|
||||||
return AUTHLIB_INJECTOR_ACCOUNT_KEY;
|
return TYPE_AUTHLIB_INJECTOR;
|
||||||
else if (account instanceof YggdrasilAccount)
|
else if (account instanceof YggdrasilAccount)
|
||||||
return YGGDRASIL_ACCOUNT_KEY;
|
return TYPE_YGGDRASIL_ACCOUNT;
|
||||||
else
|
else
|
||||||
throw new IllegalArgumentException("Failed to determine account type: " + account);
|
throw new IllegalArgumentException("Failed to determine account type: " + account);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class Settings {
|
|||||||
|
|
||||||
for (Iterator<Map<Object, Object>> iterator = CONFIG.getAccounts().iterator(); iterator.hasNext();) {
|
for (Iterator<Map<Object, Object>> iterator = CONFIG.getAccounts().iterator(); iterator.hasNext();) {
|
||||||
Map<Object, Object> settings = iterator.next();
|
Map<Object, Object> settings = iterator.next();
|
||||||
AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse(""));
|
AccountFactory<?> factory = Accounts.TYPE_TO_ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse(""));
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
LOG.warning("Unrecognized account type, removing: " + settings);
|
LOG.warning("Unrecognized account type, removing: " + settings);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user