mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-04 03:46:57 -04:00
Polish, 处理部分警告
This commit is contained in:
parent
8fd9395e23
commit
b45907a9f6
@ -106,7 +106,7 @@ public final class ModpackHelper {
|
|||||||
else throw new IllegalStateException("Unrecognized modpack: " + modpack);
|
else throw new IllegalStateException("Unrecognized modpack: " + modpack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task getUpdateTask(Profile profile, File zipFile, String name, ModpackConfiguration configuration) throws UnsupportedModpackException, MismatchedModpackTypeException, IOException {
|
public static Task getUpdateTask(Profile profile, File zipFile, String name, ModpackConfiguration<?> configuration) throws UnsupportedModpackException, MismatchedModpackTypeException, IOException {
|
||||||
Modpack modpack = ModpackHelper.readModpackManifest(zipFile);
|
Modpack modpack = ModpackHelper.readModpackManifest(zipFile);
|
||||||
|
|
||||||
switch (configuration.getType()) {
|
switch (configuration.getType()) {
|
||||||
|
@ -73,9 +73,8 @@ public final class Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<String> getCurrentCharacter(Map<Object, Object> storage) {
|
public static Optional<String> getCurrentCharacter(Map<Object, Object> storage) {
|
||||||
Optional<Map> properties = Lang.get(storage, "properties", Map.class);
|
return Lang.get(storage, "properties", Map.class)
|
||||||
if (!properties.isPresent()) return Optional.empty();
|
.flatMap(properties -> Lang.get(properties, "character", String.class));
|
||||||
return Lang.get(properties.get(), "character", String.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getAccountId(Account account) {
|
static String getAccountId(Account account) {
|
||||||
|
@ -69,7 +69,7 @@ public class Settings {
|
|||||||
{
|
{
|
||||||
for (Map<Object, Object> settings : SETTINGS.getAccounts()) {
|
for (Map<Object, Object> settings : SETTINGS.getAccounts()) {
|
||||||
Optional<String> characterName = Accounts.getCurrentCharacter(settings);
|
Optional<String> characterName = Accounts.getCurrentCharacter(settings);
|
||||||
AccountFactory factory = Accounts.ACCOUNT_FACTORY.get(Lang.get(settings, "type", String.class, ""));
|
AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(Lang.get(settings, "type", String.class, ""));
|
||||||
if (factory == null || !characterName.isPresent()) {
|
if (factory == null || !characterName.isPresent()) {
|
||||||
// unrecognized account type, so remove it.
|
// unrecognized account type, so remove it.
|
||||||
SETTINGS.getAccounts().remove(settings);
|
SETTINGS.getAccounts().remove(settings);
|
||||||
|
@ -138,7 +138,7 @@ public final class VersionSetting {
|
|||||||
permSizeProperty.set(permSize);
|
permSizeProperty.set(permSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ImmediateIntegerProperty maxMemoryProperty = new ImmediateIntegerProperty(this, "maxMemory", (int) OperatingSystem.SUGGESTED_MEMORY);
|
private final ImmediateIntegerProperty maxMemoryProperty = new ImmediateIntegerProperty(this, "maxMemory", OperatingSystem.SUGGESTED_MEMORY);
|
||||||
|
|
||||||
public ImmediateIntegerProperty maxMemoryProperty() {
|
public ImmediateIntegerProperty maxMemoryProperty() {
|
||||||
return maxMemoryProperty;
|
return maxMemoryProperty;
|
||||||
|
@ -214,19 +214,19 @@ public final class AccountsPage extends StackPane implements DecoratorPage {
|
|||||||
this.title.set(title);
|
this.title.set(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String accountException(Exception account) {
|
public static String accountException(Exception exception) {
|
||||||
if (account instanceof InvalidCredentialsException) {
|
if (exception instanceof InvalidCredentialsException) {
|
||||||
return Main.i18n("account.failed.invalid_credentials");
|
return Main.i18n("account.failed.invalid_credentials");
|
||||||
} else if (account instanceof NoCharacterException) {
|
} else if (exception instanceof NoCharacterException) {
|
||||||
return Main.i18n("account.failed.no_charactor");
|
return Main.i18n("account.failed.no_charactor");
|
||||||
} else if (account instanceof ServerDisconnectException) {
|
} else if (exception instanceof ServerDisconnectException) {
|
||||||
return Main.i18n("account.failed.connect_authentication_server");
|
return Main.i18n("account.failed.connect_authentication_server");
|
||||||
} else if (account instanceof InvalidTokenException) {
|
} else if (exception instanceof InvalidTokenException) {
|
||||||
return Main.i18n("account.failed.invalid_token");
|
return Main.i18n("account.failed.invalid_token");
|
||||||
} else if (account instanceof InvalidPasswordException) {
|
} else if (exception instanceof InvalidPasswordException) {
|
||||||
return Main.i18n("account.failed.invalid_password");
|
return Main.i18n("account.failed.invalid_password");
|
||||||
} else {
|
} else {
|
||||||
return account.getClass() + ": " + ((Exception) account).getLocalizedMessage();
|
return exception.getClass() + ": " + exception.getLocalizedMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,13 +21,9 @@ import javafx.collections.FXCollections;
|
|||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.control.MultipleSelectionModel;
|
import javafx.scene.control.MultipleSelectionModel;
|
||||||
|
|
||||||
public final class NoneMultipleSelectionModel<T> extends MultipleSelectionModel<T> {
|
public class NoneMultipleSelectionModel<T> extends MultipleSelectionModel<T> {
|
||||||
private static final NoneMultipleSelectionModel INSTANCE = new NoneMultipleSelectionModel();
|
|
||||||
private NoneMultipleSelectionModel() {}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public NoneMultipleSelectionModel() {
|
||||||
public static <T> NoneMultipleSelectionModel<T> getInstance() {
|
|
||||||
return (NoneMultipleSelectionModel<T>) INSTANCE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -217,10 +217,12 @@ public class RipplerContainer extends StackPane {
|
|||||||
private static class StyleableProperties {
|
private static class StyleableProperties {
|
||||||
|
|
||||||
private static final CssMetaData<RipplerContainer, Paint> RIPPLER_FILL = new CssMetaData<RipplerContainer, Paint>("-jfx-rippler-fill", StyleConverter.getPaintConverter(), Color.rgb(0, 200, 255)) {
|
private static final CssMetaData<RipplerContainer, Paint> RIPPLER_FILL = new CssMetaData<RipplerContainer, Paint>("-jfx-rippler-fill", StyleConverter.getPaintConverter(), Color.rgb(0, 200, 255)) {
|
||||||
|
@Override
|
||||||
public boolean isSettable(RipplerContainer control) {
|
public boolean isSettable(RipplerContainer control) {
|
||||||
return control.ripplerFill == null || !control.ripplerFill.isBound();
|
return control.ripplerFill == null || !control.ripplerFill.isBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public StyleableProperty<Paint> getStyleableProperty(RipplerContainer control) {
|
public StyleableProperty<Paint> getStyleableProperty(RipplerContainer control) {
|
||||||
return control.ripplerFillProperty();
|
return control.ripplerFillProperty();
|
||||||
}
|
}
|
||||||
@ -232,7 +234,7 @@ public class RipplerContainer extends StackPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Parent.getClassCssMetaData());
|
List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Node.getClassCssMetaData());
|
||||||
Collections.addAll(styleables, RIPPLER_FILL);
|
Collections.addAll(styleables, RIPPLER_FILL);
|
||||||
STYLEABLES = Collections.unmodifiableList(styleables);
|
STYLEABLES = Collections.unmodifiableList(styleables);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,10 @@ public final class ExportWizardProvider implements WizardProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object finish(Map<String, Object> settings) {
|
public Object finish(Map<String, Object> settings) {
|
||||||
return new HMCLModpackExportTask(profile.getRepository(), version, (List<String>) settings.get(ModpackFileSelectionPage.MODPACK_FILE_SELECTION),
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> whitelist = (List<String>) settings.get(ModpackFileSelectionPage.MODPACK_FILE_SELECTION);
|
||||||
|
|
||||||
|
return new HMCLModpackExportTask(profile.getRepository(), version, whitelist,
|
||||||
new Modpack(
|
new Modpack(
|
||||||
(String) settings.get(ModpackInfoPage.MODPACK_NAME),
|
(String) settings.get(ModpackInfoPage.MODPACK_NAME),
|
||||||
(String) settings.get(ModpackInfoPage.MODPACK_AUTHOR),
|
(String) settings.get(ModpackInfoPage.MODPACK_AUTHOR),
|
||||||
|
@ -62,7 +62,7 @@ public final class ModpackFileSelectionPage extends StackPane implements WizardP
|
|||||||
FXUtils.loadFXML(this, "/assets/fxml/modpack/selection.fxml");
|
FXUtils.loadFXML(this, "/assets/fxml/modpack/selection.fxml");
|
||||||
rootNode = getTreeItem(profile.getRepository().getRunDirectory(version), "minecraft");
|
rootNode = getTreeItem(profile.getRepository().getRunDirectory(version), "minecraft");
|
||||||
treeView.setRoot(rootNode);
|
treeView.setRoot(rootNode);
|
||||||
treeView.setSelectionModel(NoneMultipleSelectionModel.getInstance());
|
treeView.setSelectionModel(new NoneMultipleSelectionModel<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckBoxTreeItem<String> getTreeItem(File file, String basePath) {
|
private CheckBoxTreeItem<String> getTreeItem(File file, String basePath) {
|
||||||
|
@ -56,7 +56,7 @@ public class AppDataUpgrader extends IUpgrader {
|
|||||||
al.add("--noupdate");
|
al.add("--noupdate");
|
||||||
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
||||||
new URLClassLoader(new URL[]{jar.toURI().toURL()},
|
new URLClassLoader(new URL[]{jar.toURI().toURL()},
|
||||||
URLClassLoader.getSystemClassLoader().getParent()).loadClass(mainClass)
|
ClassLoader.getSystemClassLoader().getParent()).loadClass(mainClass)
|
||||||
.getMethod("main", String[].class).invoke(null, new Object[]{al.toArray(new String[0])});
|
.getMethod("main", String[].class).invoke(null, new Object[]{al.toArray(new String[0])});
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -47,6 +47,7 @@ public class OfflineAccount extends Account {
|
|||||||
throw new IllegalArgumentException("Username cannot be blank");
|
throw new IllegalArgumentException("Username cannot be blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
return UUIDTypeAdapter.fromString(uuid);
|
return UUIDTypeAdapter.fromString(uuid);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user