在添加authlib-injector服务器的过程中,传递AuthlibInjectorServerInfo而不是url
This commit is contained in:
@@ -47,6 +47,8 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
|
|||||||
|
|
||||||
private final TransitionHandler transitionHandler;
|
private final TransitionHandler transitionHandler;
|
||||||
|
|
||||||
|
private AuthlibInjectorServerInfo serverBeingAdded;
|
||||||
|
|
||||||
{
|
{
|
||||||
FXUtils.loadFXML(this, "/assets/fxml/authlib-injector-servers.fxml");
|
FXUtils.loadFXML(this, "/assets/fxml/authlib-injector-servers.fxml");
|
||||||
FXUtils.smoothScrolling(scrollPane);
|
FXUtils.smoothScrolling(scrollPane);
|
||||||
@@ -110,26 +112,28 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAddNext() {
|
private void onAddNext() {
|
||||||
String serverIp = txtServerIp.getText();
|
String url = fixInputUrl(txtServerIp.getText());
|
||||||
|
|
||||||
progressBar.setVisible(true);
|
progressBar.setVisible(true);
|
||||||
addServerPane.setDisable(true);
|
addServerPane.setDisable(true);
|
||||||
|
|
||||||
Task.ofResult("serverName", () -> Accounts.getAuthlibInjectorServerName(serverIp))
|
Task.of(() -> {
|
||||||
.finalized(Schedulers.javafx(), (variables, isDependentsSucceeded) -> {
|
serverBeingAdded = new AuthlibInjectorServerInfo(url, Accounts.getAuthlibInjectorServerName(url));
|
||||||
progressBar.setVisible(false);
|
}).finalized(Schedulers.javafx(), (variables, isDependentsSucceeded) -> {
|
||||||
addServerPane.setDisable(false);
|
progressBar.setVisible(false);
|
||||||
|
addServerPane.setDisable(false);
|
||||||
|
|
||||||
if (isDependentsSucceeded) {
|
if (isDependentsSucceeded) {
|
||||||
lblServerName.setText(variables.get("serverName"));
|
lblServerName.setText(serverBeingAdded.getServerName());
|
||||||
lblServerIp.setText(txtServerIp.getText());
|
lblServerIp.setText(serverBeingAdded.getServerIp());
|
||||||
|
|
||||||
lblServerWarning.setVisible("http".equals(NetworkUtils.toURL(serverIp).getProtocol()));
|
lblServerWarning.setVisible("http".equals(NetworkUtils.toURL(serverBeingAdded.getServerIp()).getProtocol()));
|
||||||
|
|
||||||
transitionHandler.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer());
|
|
||||||
} else
|
|
||||||
lblCreationWarning.setText(variables.<Exception>get("lastException").getLocalizedMessage());
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
|
transitionHandler.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer());
|
||||||
|
} else {
|
||||||
|
lblCreationWarning.setText(variables.<Exception>get("lastException").getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,10 +144,7 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAddFinish() {
|
private void onAddFinish() {
|
||||||
String ip = txtServerIp.getText();
|
Settings.INSTANCE.addAuthlibInjectorServerURL(serverBeingAdded.getServerIp());
|
||||||
if (!ip.endsWith("/"))
|
|
||||||
ip += "/";
|
|
||||||
Settings.INSTANCE.addAuthlibInjectorServerURL(ip);
|
|
||||||
loading();
|
loading();
|
||||||
dialog.close();
|
dialog.close();
|
||||||
}
|
}
|
||||||
@@ -160,4 +161,11 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
|
|||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title.set(title);
|
this.title.set(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String fixInputUrl(String url) {
|
||||||
|
if (!url.endsWith("/")) {
|
||||||
|
url += "/";
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user