@@ -38,9 +38,10 @@ import java.util.Collection;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class AccountHelper {
|
public final class AccountHelper {
|
||||||
public static final AccountHelper INSTANCE = new AccountHelper();
|
|
||||||
private AccountHelper() {}
|
private AccountHelper() {}
|
||||||
|
|
||||||
public static final File SKIN_DIR = new File(Launcher.HMCL_DIRECTORY, "skins");
|
public static final File SKIN_DIR = new File(Launcher.HMCL_DIRECTORY, "skins");
|
||||||
@@ -73,8 +74,8 @@ public final class AccountHelper {
|
|||||||
return new SkinLoadTask(account, proxy, true);
|
return new SkinLoadTask(account, proxy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getSkinFile(String name) {
|
private static File getSkinFile(UUID uuid) {
|
||||||
return new File(SKIN_DIR, name + ".png");
|
return new File(SKIN_DIR, uuid + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image getSkin(YggdrasilAccount account) {
|
public static Image getSkin(YggdrasilAccount account) {
|
||||||
@@ -82,9 +83,11 @@ public final class AccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Image getSkin(YggdrasilAccount account, double scaleRatio) {
|
public static Image getSkin(YggdrasilAccount account, double scaleRatio) {
|
||||||
if (account.getCharacter() == null)
|
UUID uuid = account.getUUID();
|
||||||
return getDefaultSkin(account, scaleRatio);
|
if (uuid == null)
|
||||||
File file = getSkinFile(account.getCharacter());
|
return getSteveSkin(scaleRatio);
|
||||||
|
|
||||||
|
File file = getSkinFile(uuid);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
Image original = new Image("file:" + file.getAbsolutePath());
|
Image original = new Image("file:" + file.getAbsolutePath());
|
||||||
return new Image("file:" + file.getAbsolutePath(),
|
return new Image("file:" + file.getAbsolutePath(),
|
||||||
@@ -92,15 +95,14 @@ public final class AccountHelper {
|
|||||||
original.getHeight() * scaleRatio,
|
original.getHeight() * scaleRatio,
|
||||||
false, false);
|
false, false);
|
||||||
}
|
}
|
||||||
return getDefaultSkin(account, scaleRatio);
|
return getDefaultSkin(uuid, scaleRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image getSkinImmediately(YggdrasilAccount account, GameProfile profile, double scaleRatio, Proxy proxy) throws Exception {
|
public static Image getSkinImmediately(YggdrasilAccount account, GameProfile profile, double scaleRatio, Proxy proxy) throws Exception {
|
||||||
String name = profile.getName();
|
File file = getSkinFile(profile.getId());
|
||||||
File file = getSkinFile(name);
|
|
||||||
downloadSkin(account, profile, true, proxy);
|
downloadSkin(account, profile, true, proxy);
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
return getDefaultSkin(account, scaleRatio);
|
return getDefaultSkin(profile.getId(), scaleRatio);
|
||||||
|
|
||||||
String url = "file:" + file.getAbsolutePath();
|
String url = "file:" + file.getAbsolutePath();
|
||||||
return scale(url, scaleRatio);
|
return scale(url, scaleRatio);
|
||||||
@@ -152,7 +154,7 @@ public final class AccountHelper {
|
|||||||
Optional<Texture> texture = account.getSkin(profile);
|
Optional<Texture> texture = account.getSkin(profile);
|
||||||
if (!texture.isPresent()) return;
|
if (!texture.isPresent()) return;
|
||||||
String url = texture.get().getUrl();
|
String url = texture.get().getUrl();
|
||||||
File file = getSkinFile(profile.getName());
|
File file = getSkinFile(profile.getId());
|
||||||
if (!refresh && file.exists())
|
if (!refresh && file.exists())
|
||||||
return;
|
return;
|
||||||
new FileDownloadTask(NetworkUtils.toURL(url), file, proxy).run();
|
new FileDownloadTask(NetworkUtils.toURL(url), file, proxy).run();
|
||||||
@@ -165,7 +167,7 @@ public final class AccountHelper {
|
|||||||
Optional<Texture> texture = account.getSkin();
|
Optional<Texture> texture = account.getSkin();
|
||||||
if (!texture.isPresent()) return;
|
if (!texture.isPresent()) return;
|
||||||
String url = texture.get().getUrl();
|
String url = texture.get().getUrl();
|
||||||
File file = getSkinFile(account.getCharacter());
|
File file = getSkinFile(account.getUUID());
|
||||||
if (!refresh && file.exists())
|
if (!refresh && file.exists())
|
||||||
return;
|
return;
|
||||||
new FileDownloadTask(NetworkUtils.toURL(url), file, proxy).run();
|
new FileDownloadTask(NetworkUtils.toURL(url), file, proxy).run();
|
||||||
@@ -187,11 +189,8 @@ public final class AccountHelper {
|
|||||||
return scale("/assets/img/alex.png", 4);
|
return scale("/assets/img/alex.png", 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image getDefaultSkin(Account account, double scaleRatio) {
|
public static Image getDefaultSkin(UUID uuid, double scaleRatio) {
|
||||||
if (account == null)
|
int type = uuid.hashCode() & 1;
|
||||||
return getSteveSkin(scaleRatio);
|
|
||||||
|
|
||||||
int type = account.getUUID().hashCode() & 1;
|
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
return getAlexSkin(scaleRatio);
|
return getAlexSkin(scaleRatio);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.PasswordAuthentication;
|
import java.net.PasswordAuthentication;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -62,13 +63,11 @@ public class Settings {
|
|||||||
|
|
||||||
public static final Settings INSTANCE = new Settings();
|
public static final Settings INSTANCE = new Settings();
|
||||||
|
|
||||||
private Settings() {}
|
|
||||||
|
|
||||||
private final Config SETTINGS = initSettings();
|
private final Config SETTINGS = initSettings();
|
||||||
|
|
||||||
private final Map<String, Account> accounts = new HashMap<>();
|
private final Map<String, Account> accounts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
{
|
private Settings() {
|
||||||
loadProxy();
|
loadProxy();
|
||||||
|
|
||||||
for (Iterator<Map<Object, Object>> iterator = SETTINGS.getAccounts().iterator(); iterator.hasNext(); ) {
|
for (Iterator<Map<Object, Object>> iterator = SETTINGS.getAccounts().iterator(); iterator.hasNext(); ) {
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ public class AddAccountPane extends StackPane {
|
|||||||
@FXML private JFXComboBox<String> cboType;
|
@FXML private JFXComboBox<String> cboType;
|
||||||
@FXML private JFXComboBox<TwoLineListItem> cboServers;
|
@FXML private JFXComboBox<TwoLineListItem> cboServers;
|
||||||
@FXML private JFXProgressBar progressBar;
|
@FXML private JFXProgressBar progressBar;
|
||||||
@FXML private Label lblAddInjectorServer;
|
@FXML private Label lblInjectorServer;
|
||||||
@FXML private Hyperlink linkAddInjectorServer;
|
@FXML private Hyperlink linkManageInjectorServers;
|
||||||
@FXML private JFXDialogLayout layout;
|
@FXML private JFXDialogLayout layout;
|
||||||
@FXML private JFXButton btnAccept;
|
@FXML private JFXButton btnAccept;
|
||||||
private final Consumer<Region> finalization;
|
private final Consumer<Region> finalization;
|
||||||
@@ -82,8 +82,8 @@ public class AddAccountPane extends StackPane {
|
|||||||
txtPassword.setVisible(newValue.intValue() != 0);
|
txtPassword.setVisible(newValue.intValue() != 0);
|
||||||
lblPassword.setVisible(newValue.intValue() != 0);
|
lblPassword.setVisible(newValue.intValue() != 0);
|
||||||
cboServers.setVisible(newValue.intValue() == 2);
|
cboServers.setVisible(newValue.intValue() == 2);
|
||||||
linkAddInjectorServer.setVisible(newValue.intValue() == 2);
|
linkManageInjectorServers.setVisible(newValue.intValue() == 2);
|
||||||
lblAddInjectorServer.setVisible(newValue.intValue() == 2);
|
lblInjectorServer.setVisible(newValue.intValue() == 2);
|
||||||
validateAcceptButton();
|
validateAcceptButton();
|
||||||
});
|
});
|
||||||
cboType.getSelectionModel().select(0);
|
cboType.getSelectionModel().select(0);
|
||||||
@@ -160,7 +160,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAddInjecterServer() {
|
private void onManageInjecterServers() {
|
||||||
finalization.accept(this);
|
finalization.accept(this);
|
||||||
Controllers.navigate(Controllers.getServersPage());
|
Controllers.navigate(Controllers.getServersPage());
|
||||||
}
|
}
|
||||||
@@ -208,6 +208,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
try {
|
try {
|
||||||
image = AccountHelper.getSkinImmediately(yggdrasilAccount, profile, 4, Settings.INSTANCE.getProxy());
|
image = AccountHelper.getSkinImmediately(yggdrasilAccount, profile, 4, Settings.INSTANCE.getProxy());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Logging.LOG.log(Level.WARNING, "Failed to get skin for " + profile.getName(), e);
|
||||||
image = FXUtils.DEFAULT_ICON;
|
image = FXUtils.DEFAULT_ICON;
|
||||||
}
|
}
|
||||||
ImageView portraitView = new ImageView();
|
ImageView portraitView = new ImageView();
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public final class LeftPaneController {
|
|||||||
Image image = AccountHelper.getSkin((YggdrasilAccount) account, 4);
|
Image image = AccountHelper.getSkin((YggdrasilAccount) account, 4);
|
||||||
item.setImage(image, AccountHelper.getViewport(4));
|
item.setImage(image, AccountHelper.getViewport(4));
|
||||||
} else
|
} else
|
||||||
item.setImage(AccountHelper.getDefaultSkin(account, 4), AccountHelper.getViewport(4));
|
item.setImage(AccountHelper.getDefaultSkin(account.getUUID(), 4), AccountHelper.getViewport(4));
|
||||||
|
|
||||||
if (account instanceof AuthlibInjectorAccount)
|
if (account instanceof AuthlibInjectorAccount)
|
||||||
Accounts.getAuthlibInjectorServerNameAsync((AuthlibInjectorAccount) account)
|
Accounts.getAuthlibInjectorServerNameAsync((AuthlibInjectorAccount) account)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import javafx.animation.Timeline;
|
|||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
|
|
||||||
public final class TransitionHandler implements AnimationHandler {
|
public final class TransitionHandler implements AnimationHandler {
|
||||||
@@ -36,6 +37,12 @@ public final class TransitionHandler implements AnimationHandler {
|
|||||||
public TransitionHandler(StackPane view) {
|
public TransitionHandler(StackPane view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
currentNode = view.getChildren().stream().findFirst().orElse(null);
|
currentNode = view.getChildren().stream().findFirst().orElse(null);
|
||||||
|
|
||||||
|
// prevent content overflow
|
||||||
|
Rectangle clip = new Rectangle();
|
||||||
|
clip.widthProperty().bind(view.widthProperty());
|
||||||
|
clip.heightProperty().bind(view.heightProperty());
|
||||||
|
view.setClip(clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
<JFXComboBox fx:id="cboType" GridPane.columnIndex="1" GridPane.rowIndex="0" GridPane.columnSpan="2"/>
|
<JFXComboBox fx:id="cboType" GridPane.columnIndex="1" GridPane.rowIndex="0" GridPane.columnSpan="2"/>
|
||||||
|
|
||||||
<Label fx:id="lblAddInjectorServer" text="%account.injector.server" GridPane.halignment="RIGHT"
|
<Label fx:id="lblInjectorServer" text="%account.injector.server" GridPane.halignment="RIGHT"
|
||||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||||
|
|
||||||
<JFXComboBox fx:id="cboServers" maxHeight="25" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
<JFXComboBox fx:id="cboServers" maxHeight="25" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
|
|
||||||
<Hyperlink fx:id="linkAddInjectorServer" text="%account.injector.add"
|
<Hyperlink fx:id="linkManageInjectorServers" text="%account.injector.manage"
|
||||||
onMouseClicked="#onAddInjecterServer" GridPane.columnIndex="2" GridPane.rowIndex="1"/>
|
onMouseClicked="#onManageInjecterServers" GridPane.columnIndex="2" GridPane.rowIndex="1"/>
|
||||||
|
|
||||||
<Label text="%account.username" GridPane.rowIndex="2" GridPane.columnIndex="0"/>
|
<Label text="%account.username" GridPane.rowIndex="2" GridPane.columnIndex="0"/>
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ account.failed.invalid_credentials=Incorrect password. Or forbidden to log in te
|
|||||||
account.failed.invalid_password=Invalid password
|
account.failed.invalid_password=Invalid password
|
||||||
account.failed.invalid_token=Please log out and re-input your password to log in.
|
account.failed.invalid_token=Please log out and re-input your password to log in.
|
||||||
account.failed.no_charactor=No character in this account.
|
account.failed.no_charactor=No character in this account.
|
||||||
account.injector.add=Add new authentication server
|
account.injector.add=Add authentication server
|
||||||
|
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_ip=Server URL
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ account.failed.invalid_credentials=您的用户名或密码错误,或者登录
|
|||||||
account.failed.invalid_password=无效的密码
|
account.failed.invalid_password=无效的密码
|
||||||
account.failed.invalid_token=请尝试登出并重新输入密码登录
|
account.failed.invalid_token=请尝试登出并重新输入密码登录
|
||||||
account.failed.no_charactor=该帐号没有角色
|
account.failed.no_charactor=该帐号没有角色
|
||||||
account.injector.add=添加登录认证服务器
|
account.injector.add=添加认证服务器
|
||||||
|
account.injector.manage=管理认证服务器
|
||||||
account.injector.http=警告:此服务器使用不安全的http协议,您的密码在登录时会被明文传输。
|
account.injector.http=警告:此服务器使用不安全的http协议,您的密码在登录时会被明文传输。
|
||||||
account.injector.server=认证服务器
|
account.injector.server=认证服务器
|
||||||
account.injector.server_ip=服务器地址
|
account.injector.server_ip=服务器地址
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class YggdrasilAccount extends Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
if (session == null)
|
if (session == null || session.getSelectedProfile() == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
return session.getSelectedProfile().getId();
|
return session.getSelectedProfile().getId();
|
||||||
|
|||||||
Reference in New Issue
Block a user