mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-13 22:07:01 -04:00
parent
cc8a4ddf19
commit
371295d9fe
@ -224,49 +224,51 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
|||||||
additionalData = null;
|
additionalData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (factory instanceof OfflineAccountFactory && username != null) {
|
Runnable doCreate = () -> {
|
||||||
if (!USERNAME_CHECKER_PATTERN.matcher(username).matches()) {
|
logging.set(true);
|
||||||
Controllers.confirm(
|
deviceCode.set(null);
|
||||||
i18n("account.methods.offline.name.invalid"), i18n("message.warning"),
|
|
||||||
MessageDialogPane.MessageType.WARNING,
|
|
||||||
() -> {
|
|
||||||
logging.set(true);
|
|
||||||
deviceCode.set(null);
|
|
||||||
|
|
||||||
loginTask = Task.supplyAsync(() -> factory.create(new DialogCharacterSelector(), username, password, null, additionalData))
|
loginTask = Task.supplyAsync(() -> factory.create(new DialogCharacterSelector(), username, password, null, additionalData))
|
||||||
.whenComplete(Schedulers.javafx(), account -> {
|
.whenComplete(Schedulers.javafx(), account -> {
|
||||||
int oldIndex = Accounts.getAccounts().indexOf(account);
|
int oldIndex = Accounts.getAccounts().indexOf(account);
|
||||||
if (oldIndex == -1) {
|
if (oldIndex == -1) {
|
||||||
Accounts.getAccounts().add(account);
|
Accounts.getAccounts().add(account);
|
||||||
} else {
|
} else {
|
||||||
// adding an already-added account
|
// adding an already-added account
|
||||||
// instead of discarding the new account, we first remove the existing one then add the new one
|
// instead of discarding the new account, we first remove the existing one then add the new one
|
||||||
Accounts.getAccounts().remove(oldIndex);
|
Accounts.getAccounts().remove(oldIndex);
|
||||||
Accounts.getAccounts().add(oldIndex, account);
|
Accounts.getAccounts().add(oldIndex, account);
|
||||||
}
|
|
||||||
|
|
||||||
// select the new account
|
|
||||||
Accounts.setSelectedAccount(account);
|
|
||||||
|
|
||||||
spinner.hideSpinner();
|
|
||||||
fireEvent(new DialogCloseEvent());
|
|
||||||
}, exception -> {
|
|
||||||
if (exception instanceof NoSelectedCharacterException) {
|
|
||||||
fireEvent(new DialogCloseEvent());
|
|
||||||
} else {
|
|
||||||
lblErrorMessage.setText(Accounts.localizeErrorMessage(exception));
|
|
||||||
}
|
|
||||||
body.setDisable(false);
|
|
||||||
spinner.hideSpinner();
|
|
||||||
}).executor(true);
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
lblErrorMessage.setText(i18n("account.methods.offline.name.invalid"));
|
|
||||||
body.setDisable(false);
|
|
||||||
spinner.hideSpinner();
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
// select the new account
|
||||||
|
Accounts.setSelectedAccount(account);
|
||||||
|
|
||||||
|
spinner.hideSpinner();
|
||||||
|
fireEvent(new DialogCloseEvent());
|
||||||
|
}, exception -> {
|
||||||
|
if (exception instanceof NoSelectedCharacterException) {
|
||||||
|
fireEvent(new DialogCloseEvent());
|
||||||
|
} else {
|
||||||
|
lblErrorMessage.setText(Accounts.localizeErrorMessage(exception));
|
||||||
|
}
|
||||||
|
body.setDisable(false);
|
||||||
|
spinner.hideSpinner();
|
||||||
|
}).executor(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (factory instanceof OfflineAccountFactory && username != null && !USERNAME_CHECKER_PATTERN.matcher(username).matches()) {
|
||||||
|
Controllers.confirm(
|
||||||
|
i18n("account.methods.offline.name.invalid"), i18n("message.warning"),
|
||||||
|
MessageDialogPane.MessageType.WARNING,
|
||||||
|
doCreate,
|
||||||
|
() -> {
|
||||||
|
lblErrorMessage.setText(i18n("account.methods.offline.name.invalid"));
|
||||||
|
body.setDisable(false);
|
||||||
|
spinner.hideSpinner();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
doCreate.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +372,7 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
|||||||
private static class AccountDetailsInputPane extends GridPane {
|
private static class AccountDetailsInputPane extends GridPane {
|
||||||
|
|
||||||
// ==== authlib-injector hyperlinks ====
|
// ==== authlib-injector hyperlinks ====
|
||||||
private static final String[] ALLOWED_LINKS = { "homepage", "register" };
|
private static final String[] ALLOWED_LINKS = {"homepage", "register"};
|
||||||
|
|
||||||
private static List<Hyperlink> createHyperlinks(AuthlibInjectorServer server) {
|
private static List<Hyperlink> createHyperlinks(AuthlibInjectorServer server) {
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user