AuthlibInjectorServerInfo重命名为AuthlibInjectorServer

更正其它措辞:ip->url
This commit is contained in:
yushijinhun 2018-06-16 19:31:23 +08:00
parent ba8cdb1b42
commit 10d4084dde
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
9 changed files with 48 additions and 48 deletions

View File

@ -21,7 +21,7 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.jackhuang.hmcl.Launcher; import org.jackhuang.hmcl.Launcher;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServerInfo; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -99,7 +99,7 @@ public final class Config implements Cloneable {
@SerializedName("logLines") @SerializedName("logLines")
public final IntegerProperty logLines = new SimpleIntegerProperty(100); public final IntegerProperty logLines = new SimpleIntegerProperty(100);
public final ObservableList<AuthlibInjectorServerInfo> authlibInjectorServers = FXCollections.observableArrayList(); public final ObservableList<AuthlibInjectorServer> authlibInjectorServers = FXCollections.observableArrayList();
@Override @Override
public Config clone() { public Config clone() {

View File

@ -36,7 +36,7 @@ import org.jackhuang.hmcl.Launcher;
import org.jackhuang.hmcl.auth.Account; import org.jackhuang.hmcl.auth.Account;
import org.jackhuang.hmcl.auth.AccountFactory; import org.jackhuang.hmcl.auth.AccountFactory;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorAccount;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServerInfo; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
import org.jackhuang.hmcl.download.DownloadProvider; import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.event.*; import org.jackhuang.hmcl.event.*;
import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Schedulers;
@ -314,13 +314,13 @@ public class Settings {
private Set<String> getAuthlibInjectorServerUrls() { private Set<String> getAuthlibInjectorServerUrls() {
return SETTINGS.authlibInjectorServers.stream() return SETTINGS.authlibInjectorServers.stream()
.map(AuthlibInjectorServerInfo::getServerIp) .map(AuthlibInjectorServer::getUrl)
.collect(toSet()); .collect(toSet());
} }
/** /**
* The {@code serverBaseURL} specified in {@link AuthlibInjectorAccount} may not have an associated * The {@code serverBaseURL} specified in {@link AuthlibInjectorAccount} may not have an associated
* {@link AuthlibInjectorServerInfo} in {@link Config#authlibInjectorServers}, * {@link AuthlibInjectorServer} in {@link Config#authlibInjectorServers},
* which usually happens when migrating data from an older version. * which usually happens when migrating data from an older version.
* This method adds the missing servers to {@link Config#authlibInjectorServers}. * This method adds the missing servers to {@link Config#authlibInjectorServers}.
*/ */
@ -340,12 +340,12 @@ public class Settings {
serverName = url; serverName = url;
Logging.LOG.log(Level.WARNING, "Failed to migrate authlib injector server [" + url + "]", e); Logging.LOG.log(Level.WARNING, "Failed to migrate authlib injector server [" + url + "]", e);
} }
SETTINGS.authlibInjectorServers.add(new AuthlibInjectorServerInfo(url, serverName)); SETTINGS.authlibInjectorServers.add(new AuthlibInjectorServer(url, serverName));
}); });
} }
/** /**
* After an {@link AuthlibInjectorServerInfo} is removed, the associated accounts should also be removed. * After an {@link AuthlibInjectorServer} is removed, the associated accounts should also be removed.
* This method performs a check and removes the dangling accounts. * This method performs a check and removes the dangling accounts.
* Don't call this before {@link #migrateAuthlibInjectorServers()} is called, otherwise old data would be lost. * Don't call this before {@link #migrateAuthlibInjectorServers()} is called, otherwise old data would be lost.
*/ */

View File

@ -110,7 +110,7 @@ public class AddAccountPane extends StackPane {
private void loadServers() { private void loadServers() {
cboServers.getItems().setAll( cboServers.getItems().setAll(
Settings.INSTANCE.SETTINGS.authlibInjectorServers.stream() Settings.INSTANCE.SETTINGS.authlibInjectorServers.stream()
.map(server -> new TwoLineListItem(server.getServerName(), server.getServerIp())) .map(server -> new TwoLineListItem(server.getName(), server.getUrl()))
.collect(toList())); .collect(toList()));
if (!cboServers.getItems().isEmpty()) if (!cboServers.getItems().isEmpty())
cboServers.getSelectionModel().select(0); cboServers.getSelectionModel().select(0);

View File

@ -23,19 +23,19 @@ import javafx.geometry.Pos;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServerInfo; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.setting.Theme;
import java.util.function.Consumer; import java.util.function.Consumer;
public final class AuthlibInjectorServerItem extends BorderPane { public final class AuthlibInjectorServerItem extends BorderPane {
private final AuthlibInjectorServerInfo info; private final AuthlibInjectorServer server;
private final Label lblServerName = new Label(); private final Label lblServerName = new Label();
private final Label lblServerIp = new Label(); private final Label lblServerIp = new Label();
public AuthlibInjectorServerItem(AuthlibInjectorServerInfo info, Consumer<AuthlibInjectorServerItem> deleteCallback) { public AuthlibInjectorServerItem(AuthlibInjectorServer server, Consumer<AuthlibInjectorServerItem> deleteCallback) {
this.info = info; this.server = server;
lblServerName.setStyle("-fx-font-size: 15;"); lblServerName.setStyle("-fx-font-size: 15;");
lblServerIp.setStyle("-fx-font-size: 10;"); lblServerIp.setStyle("-fx-font-size: 10;");
@ -54,11 +54,11 @@ public final class AuthlibInjectorServerItem extends BorderPane {
setStyle("-fx-background-radius: 2; -fx-background-color: white; -fx-padding: 8;"); setStyle("-fx-background-radius: 2; -fx-background-color: white; -fx-padding: 8;");
JFXDepthManager.setDepth(this, 1); JFXDepthManager.setDepth(this, 1);
lblServerName.setText(info.getServerName()); lblServerName.setText(server.getName());
lblServerIp.setText(info.getServerIp()); lblServerIp.setText(server.getUrl());
} }
public AuthlibInjectorServerInfo getInfo() { public AuthlibInjectorServer getServer() {
return info; return server;
} }
} }

View File

@ -9,7 +9,7 @@ import javafx.scene.control.ScrollPane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import org.jackhuang.hmcl.Launcher; import org.jackhuang.hmcl.Launcher;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServerInfo; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
import org.jackhuang.hmcl.setting.Accounts; import org.jackhuang.hmcl.setting.Accounts;
import org.jackhuang.hmcl.setting.Settings; import org.jackhuang.hmcl.setting.Settings;
import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Schedulers;
@ -26,12 +26,12 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
@FXML private ScrollPane scrollPane; @FXML private ScrollPane scrollPane;
@FXML private StackPane addServerContainer; @FXML private StackPane addServerContainer;
@FXML private Label lblServerIp; @FXML private Label lblServerUrl;
@FXML private Label lblServerName; @FXML private Label lblServerName;
@FXML private Label lblCreationWarning; @FXML private Label lblCreationWarning;
@FXML private Label lblServerWarning; @FXML private Label lblServerWarning;
@FXML private VBox listPane; @FXML private VBox listPane;
@FXML private JFXTextField txtServerIp; @FXML private JFXTextField txtServerUrl;
@FXML private JFXDialogLayout addServerPane; @FXML private JFXDialogLayout addServerPane;
@FXML private JFXDialogLayout confirmServerPane; @FXML private JFXDialogLayout confirmServerPane;
@FXML private JFXDialog dialog; @FXML private JFXDialog dialog;
@ -41,7 +41,7 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
private final TransitionHandler transitionHandler; private final TransitionHandler transitionHandler;
private AuthlibInjectorServerInfo serverBeingAdded; private AuthlibInjectorServer serverBeingAdded;
{ {
FXUtils.loadFXML(this, "/assets/fxml/authlib-injector-servers.fxml"); FXUtils.loadFXML(this, "/assets/fxml/authlib-injector-servers.fxml");
@ -51,14 +51,14 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
getChildren().remove(dialog); getChildren().remove(dialog);
dialog.setDialogContainer(this); dialog.setDialogContainer(this);
txtServerIp.textProperty().addListener((a, b, newValue) -> txtServerUrl.textProperty().addListener((a, b, newValue) ->
btnAddNext.setDisable(!txtServerIp.validate())); btnAddNext.setDisable(!txtServerUrl.validate()));
reload(); reload();
} }
private void removeServer(AuthlibInjectorServerItem item) { private void removeServer(AuthlibInjectorServerItem item) {
Settings.INSTANCE.SETTINGS.authlibInjectorServers.remove(item.getInfo()); Settings.INSTANCE.SETTINGS.authlibInjectorServers.remove(item.getServer());
reload(); reload();
} }
@ -75,7 +75,7 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
@FXML @FXML
private void onAdd() { private void onAdd() {
transitionHandler.setContent(addServerPane, ContainerAnimations.NONE.getAnimationProducer()); transitionHandler.setContent(addServerPane, ContainerAnimations.NONE.getAnimationProducer());
txtServerIp.setText(""); txtServerUrl.setText("");
addServerPane.setDisable(false); addServerPane.setDisable(false);
progressBar.setVisible(false); progressBar.setVisible(false);
dialog.show(); dialog.show();
@ -88,22 +88,22 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
@FXML @FXML
private void onAddNext() { private void onAddNext() {
String url = fixInputUrl(txtServerIp.getText()); String url = fixInputUrl(txtServerUrl.getText());
progressBar.setVisible(true); progressBar.setVisible(true);
addServerPane.setDisable(true); addServerPane.setDisable(true);
Task.of(() -> { Task.of(() -> {
serverBeingAdded = new AuthlibInjectorServerInfo(url, Accounts.getAuthlibInjectorServerName(url)); serverBeingAdded = new AuthlibInjectorServer(url, Accounts.getAuthlibInjectorServerName(url));
}).finalized(Schedulers.javafx(), (variables, isDependentsSucceeded) -> { }).finalized(Schedulers.javafx(), (variables, isDependentsSucceeded) -> {
progressBar.setVisible(false); progressBar.setVisible(false);
addServerPane.setDisable(false); addServerPane.setDisable(false);
if (isDependentsSucceeded) { if (isDependentsSucceeded) {
lblServerName.setText(serverBeingAdded.getServerName()); lblServerName.setText(serverBeingAdded.getName());
lblServerIp.setText(serverBeingAdded.getServerIp()); lblServerUrl.setText(serverBeingAdded.getUrl());
lblServerWarning.setVisible("http".equals(NetworkUtils.toURL(serverBeingAdded.getServerIp()).getProtocol())); lblServerWarning.setVisible("http".equals(NetworkUtils.toURL(serverBeingAdded.getUrl()).getProtocol()));
transitionHandler.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer()); transitionHandler.setContent(confirmServerPane, ContainerAnimations.SWIPE_LEFT.getAnimationProducer());
} else { } else {

View File

@ -31,7 +31,7 @@
<Label text="%account.injector.add" /> <Label text="%account.injector.add" />
</heading> </heading>
<body> <body>
<JFXTextField fx:id="txtServerIp" promptText="%account.injector.server_ip"> <JFXTextField fx:id="txtServerUrl" promptText="%account.injector.server_url">
<validators> <validators>
<URLValidator message="%input.url"> <URLValidator message="%input.url">
</URLValidator> </URLValidator>
@ -61,10 +61,10 @@
<ColumnConstraints maxWidth="100" /> <ColumnConstraints maxWidth="100" />
<ColumnConstraints /> <ColumnConstraints />
</columnConstraints> </columnConstraints>
<Label text="%account.injector.server_ip" GridPane.columnIndex="0" GridPane.rowIndex="0" /> <Label text="%account.injector.server_url" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<Label text="%account.injector.server_name" GridPane.columnIndex="0" GridPane.rowIndex="1" /> <Label text="%account.injector.server_name" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Label fx:id="lblServerIp" GridPane.columnIndex="1" GridPane.rowIndex="0" /> <Label fx:id="lblServerUrl" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<Label fx:id="lblServerName" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <Label fx:id="lblServerName" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label fx:id="lblServerWarning" text="%account.injector.http" style="-fx-text-fill: red;" GridPane.rowIndex="2" GridPane.columnSpan="2" GridPane.columnIndex="0" /> <Label fx:id="lblServerWarning" text="%account.injector.http" style="-fx-text-fill: red;" GridPane.rowIndex="2" GridPane.columnSpan="2" GridPane.columnIndex="0" />

View File

@ -43,7 +43,7 @@ account.injector.add=Add authentication server
account.injector.manage=Manage authentication servers account.injector.manage=Manage authentication servers
account.injector.http=Warning: This server is using HTTP, which will cause your password be transmitted in clear text. account.injector.http=Warning: This server is using HTTP, which will cause your password be transmitted in clear text.
account.injector.server=Auth Server account.injector.server=Auth Server
account.injector.server_ip=Server URL account.injector.server_url=Server URL
account.injector.server_name=Server Name account.injector.server_name=Server Name
account.methods=Login Type account.methods=Login Type
account.methods.authlib_injector=authlib-injector account.methods.authlib_injector=authlib-injector

View File

@ -43,7 +43,7 @@ account.injector.add=添加认证服务器
account.injector.manage=管理认证服务器 account.injector.manage=管理认证服务器
account.injector.http=警告此服务器使用不安全的http协议您的密码在登录时会被明文传输。 account.injector.http=警告此服务器使用不安全的http协议您的密码在登录时会被明文传输。
account.injector.server=认证服务器 account.injector.server=认证服务器
account.injector.server_ip=服务器地址 account.injector.server_url=服务器地址
account.injector.server_name=服务器名称 account.injector.server_name=服务器名称
account.methods=登录方式 account.methods=登录方式
account.methods.authlib_injector=authlib-injector 登录 account.methods.authlib_injector=authlib-injector 登录

View File

@ -17,35 +17,35 @@
*/ */
package org.jackhuang.hmcl.auth.authlibinjector; package org.jackhuang.hmcl.auth.authlibinjector;
public class AuthlibInjectorServerInfo { public class AuthlibInjectorServer {
private final String serverIp; private String url;
private final String serverName; private String name;
public AuthlibInjectorServerInfo(String serverIp, String serverName) { public AuthlibInjectorServer(String url, String name) {
this.serverIp = serverIp; this.url = url;
this.serverName = serverName; this.name = name;
} }
public String getServerIp() { public String getUrl() {
return serverIp; return url;
} }
public String getServerName() { public String getName() {
return serverName; return name;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return serverIp.hashCode(); return url.hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == this) if (obj == this)
return true; return true;
if (!(obj instanceof AuthlibInjectorServerInfo)) if (!(obj instanceof AuthlibInjectorServer))
return false; return false;
AuthlibInjectorServerInfo another = (AuthlibInjectorServerInfo) obj; AuthlibInjectorServer another = (AuthlibInjectorServer) obj;
return this.serverIp.equals(another.serverIp); return this.url.equals(another.url);
} }
} }