name task async
This commit is contained in:
@@ -46,7 +46,7 @@ public final class Main {
|
|||||||
checkDirectoryPath();
|
checkDirectoryPath();
|
||||||
|
|
||||||
// This environment check will take ~300ms
|
// This environment check will take ~300ms
|
||||||
thread(() -> checkDSTRootCAX3(), "CA Certificate Check", true);
|
thread(Main::checkDSTRootCAX3, "CA Certificate Check", true);
|
||||||
|
|
||||||
Logging.start(Metadata.HMCL_DIRECTORY.resolve("logs"));
|
Logging.start(Metadata.HMCL_DIRECTORY.resolve("logs"));
|
||||||
|
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ public final class LauncherHelper {
|
|||||||
Optional<String> gameVersion = GameVersion.minecraftVersion(repository.getVersionJar(version));
|
Optional<String> gameVersion = GameVersion.minecraftVersion(repository.getVersionJar(version));
|
||||||
|
|
||||||
TaskExecutor executor = Task.runAsync(Schedulers.javafx(), () -> emitStatus(LoadingState.DEPENDENCIES))
|
TaskExecutor executor = Task.runAsync(Schedulers.javafx(), () -> emitStatus(LoadingState.DEPENDENCIES))
|
||||||
.thenCompose(() -> {
|
.thenComposeAsync(() -> {
|
||||||
if (setting.isNotCheckGame())
|
if (setting.isNotCheckGame())
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
return dependencyManager.checkGameCompletionAsync(version);
|
return dependencyManager.checkGameCompletionAsync(version);
|
||||||
})
|
})
|
||||||
.thenRun(Schedulers.javafx(), () -> emitStatus(LoadingState.MODS))
|
.thenRunAsync(Schedulers.javafx(), () -> emitStatus(LoadingState.MODS))
|
||||||
.thenCompose(() -> {
|
.thenComposeAsync(() -> {
|
||||||
try {
|
try {
|
||||||
ModpackConfiguration<?> configuration = ModpackHelper.readModpackConfiguration(repository.getModpackConfiguration(selectedVersion));
|
ModpackConfiguration<?> configuration = ModpackHelper.readModpackConfiguration(repository.getModpackConfiguration(selectedVersion));
|
||||||
if ("Curse".equals(configuration.getType()))
|
if ("Curse".equals(configuration.getType()))
|
||||||
@@ -141,8 +141,8 @@ public final class LauncherHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.thenRun(Schedulers.javafx(), () -> emitStatus(LoadingState.LOGGING_IN))
|
.thenRunAsync(Schedulers.javafx(), () -> emitStatus(LoadingState.LOGGING_IN))
|
||||||
.thenSupply(i18n("account.methods"), () -> {
|
.thenSupplyAsync(i18n("account.methods"), () -> {
|
||||||
try {
|
try {
|
||||||
return account.logIn();
|
return account.logIn();
|
||||||
} catch (CredentialExpiredException e) {
|
} catch (CredentialExpiredException e) {
|
||||||
@@ -153,11 +153,11 @@ public final class LauncherHelper {
|
|||||||
return account.playOffline().orElseThrow(() -> e);
|
return account.playOffline().orElseThrow(() -> e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.thenApply(Schedulers.javafx(), authInfo -> {
|
.thenApplyAsync(Schedulers.javafx(), authInfo -> {
|
||||||
emitStatus(LoadingState.LAUNCHING);
|
emitStatus(LoadingState.LAUNCHING);
|
||||||
return authInfo;
|
return authInfo;
|
||||||
})
|
})
|
||||||
.thenApply(authInfo -> new HMCLGameLauncher(
|
.thenApplyAsync(authInfo -> new HMCLGameLauncher(
|
||||||
repository,
|
repository,
|
||||||
selectedVersion,
|
selectedVersion,
|
||||||
authInfo,
|
authInfo,
|
||||||
@@ -166,7 +166,7 @@ public final class LauncherHelper {
|
|||||||
? null // Unnecessary to start listening to game process output when close launcher immediately after game launched.
|
? null // Unnecessary to start listening to game process output when close launcher immediately after game launched.
|
||||||
: new HMCLProcessListener(authInfo, gameVersion.isPresent())
|
: new HMCLProcessListener(authInfo, gameVersion.isPresent())
|
||||||
))
|
))
|
||||||
.thenCompose(launcher -> { // launcher is prev task's result
|
.thenComposeAsync(launcher -> { // launcher is prev task's result
|
||||||
if (scriptFile == null) {
|
if (scriptFile == null) {
|
||||||
return new LaunchTask<>(launcher::launch).setName(i18n("version.launch"));
|
return new LaunchTask<>(launcher::launch).setName(i18n("version.launch"));
|
||||||
} else {
|
} else {
|
||||||
@@ -176,7 +176,7 @@ public final class LauncherHelper {
|
|||||||
}).setName(i18n("version.launch_script"));
|
}).setName(i18n("version.launch_script"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.thenAccept(process -> { // process is LaunchTask's result
|
.thenAcceptAsync(process -> { // process is LaunchTask's result
|
||||||
if (scriptFile == null) {
|
if (scriptFile == null) {
|
||||||
PROCESSES.add(process);
|
PROCESSES.add(process);
|
||||||
if (launcherVisibility == LauncherVisibility.CLOSE)
|
if (launcherVisibility == LauncherVisibility.CLOSE)
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public final class ModpackHelper {
|
|||||||
else if (modpack.getManifest() instanceof MultiMCInstanceConfiguration)
|
else if (modpack.getManifest() instanceof MultiMCInstanceConfiguration)
|
||||||
return new MultiMCModpackInstallTask(profile.getDependency(), zipFile, modpack, ((MultiMCInstanceConfiguration) modpack.getManifest()), name)
|
return new MultiMCModpackInstallTask(profile.getDependency(), zipFile, modpack, ((MultiMCInstanceConfiguration) modpack.getManifest()), name)
|
||||||
.whenComplete(Schedulers.defaultScheduler(), success, failure)
|
.whenComplete(Schedulers.defaultScheduler(), success, failure)
|
||||||
.thenCompose(new MultiMCInstallVersionSettingTask(profile, ((MultiMCInstanceConfiguration) modpack.getManifest()), name));
|
.thenComposeAsync(new MultiMCInstallVersionSettingTask(profile, ((MultiMCInstanceConfiguration) modpack.getManifest()), name));
|
||||||
else throw new IllegalStateException("Unrecognized modpack: " + modpack);
|
else throw new IllegalStateException("Unrecognized modpack: " + modpack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public final class Profile implements Observable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Profile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public Profile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
if (json == null || json == JsonNull.INSTANCE || !(json instanceof JsonObject)) return null;
|
if (json == JsonNull.INSTANCE || !(json instanceof JsonObject)) return null;
|
||||||
JsonObject obj = (JsonObject) json;
|
JsonObject obj = (JsonObject) json;
|
||||||
String gameDir = Optional.ofNullable(obj.get("gameDir")).map(JsonElement::getAsString).orElse("");
|
String gameDir = Optional.ofNullable(obj.get("gameDir")).map(JsonElement::getAsString).orElse("");
|
||||||
|
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ public final class VersionSetting {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VersionSetting deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public VersionSetting deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
if (json == null || json == JsonNull.INSTANCE || !(json instanceof JsonObject))
|
if (json == JsonNull.INSTANCE || !(json instanceof JsonObject))
|
||||||
return null;
|
return null;
|
||||||
JsonObject obj = (JsonObject) json;
|
JsonObject obj = (JsonObject) json;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.ui;
|
package org.jackhuang.hmcl.ui;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.scene.layout.Region;
|
|
||||||
import org.jackhuang.hmcl.event.EventBus;
|
import org.jackhuang.hmcl.event.EventBus;
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
||||||
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
||||||
@@ -28,7 +27,6 @@ import org.jackhuang.hmcl.setting.Profile;
|
|||||||
import org.jackhuang.hmcl.setting.Profiles;
|
import org.jackhuang.hmcl.setting.Profiles;
|
||||||
import org.jackhuang.hmcl.task.Schedulers;
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
import org.jackhuang.hmcl.task.TaskExecutor;
|
|
||||||
import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem;
|
import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem;
|
||||||
import org.jackhuang.hmcl.ui.account.AddAccountPane;
|
import org.jackhuang.hmcl.ui.account.AddAccountPane;
|
||||||
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
|
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
|
||||||
@@ -39,7 +37,6 @@ import org.jackhuang.hmcl.ui.versions.Versions;
|
|||||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.newImage;
|
import static org.jackhuang.hmcl.ui.FXUtils.newImage;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.runInFX;
|
import static org.jackhuang.hmcl.ui.FXUtils.runInFX;
|
||||||
@@ -119,10 +116,10 @@ public final class LeftPaneController extends AdvancedListBox {
|
|||||||
File modpackFile = new File("modpack.zip").getAbsoluteFile();
|
File modpackFile = new File("modpack.zip").getAbsoluteFile();
|
||||||
if (modpackFile.exists()) {
|
if (modpackFile.exists()) {
|
||||||
Task.supplyAsync(() -> CompressingUtils.findSuitableEncoding(modpackFile.toPath()))
|
Task.supplyAsync(() -> CompressingUtils.findSuitableEncoding(modpackFile.toPath()))
|
||||||
.thenApply(encoding -> ModpackHelper.readModpackManifest(modpackFile.toPath(), encoding))
|
.thenApplyAsync(encoding -> ModpackHelper.readModpackManifest(modpackFile.toPath(), encoding))
|
||||||
.thenApply(modpack -> ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack)
|
.thenApplyAsync(modpack -> ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack)
|
||||||
.withRun(Schedulers.javafx(), this::checkAccount).executor())
|
.withRunAsync(Schedulers.javafx(), this::checkAccount).executor())
|
||||||
.thenAccept(Schedulers.javafx(), executor -> {
|
.thenAcceptAsync(Schedulers.javafx(), executor -> {
|
||||||
Controllers.taskDialog(executor, i18n("modpack.installing"));
|
Controllers.taskDialog(executor, i18n("modpack.installing"));
|
||||||
executor.start();
|
executor.start();
|
||||||
}).start();
|
}).start();
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -118,7 +117,7 @@ public final class SettingsPage extends SettingsView implements DecoratorPage {
|
|||||||
selectedItemPropertyFor(proxyConfigurationGroup, Proxy.Type.class).bindBidirectional(config().proxyTypeProperty());
|
selectedItemPropertyFor(proxyConfigurationGroup, Proxy.Type.class).bindBidirectional(config().proxyTypeProperty());
|
||||||
// ====
|
// ====
|
||||||
|
|
||||||
fileCommonLocation.loadChildren(Arrays.asList(
|
fileCommonLocation.loadChildren(Collections.singletonList(
|
||||||
fileCommonLocation.createChildren(i18n("launcher.cache_directory.default"), EnumCommonDirectory.DEFAULT)
|
fileCommonLocation.createChildren(i18n("launcher.cache_directory.default"), EnumCommonDirectory.DEFAULT)
|
||||||
), EnumCommonDirectory.CUSTOM);
|
), EnumCommonDirectory.CUSTOM);
|
||||||
fileCommonLocation.selectedDataProperty().bindBidirectional(config().commonDirTypeProperty());
|
fileCommonLocation.selectedDataProperty().bindBidirectional(config().commonDirTypeProperty());
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
@FXML private SpinnerPane acceptPane;
|
@FXML private SpinnerPane acceptPane;
|
||||||
@FXML private HBox linksContainer;
|
@FXML private HBox linksContainer;
|
||||||
|
|
||||||
private ListProperty<Hyperlink> links = new SimpleListProperty<>();;
|
private ListProperty<Hyperlink> links = new SimpleListProperty<>();
|
||||||
|
|
||||||
public AddAccountPane() {
|
public AddAccountPane() {
|
||||||
FXUtils.loadFXML(this, "/assets/fxml/account-add.fxml");
|
FXUtils.loadFXML(this, "/assets/fxml/account-add.fxml");
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ import javafx.beans.binding.Bindings;
|
|||||||
import javafx.beans.property.ReadOnlyStringProperty;
|
import javafx.beans.property.ReadOnlyStringProperty;
|
||||||
import javafx.beans.property.ReadOnlyStringWrapper;
|
import javafx.beans.property.ReadOnlyStringWrapper;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.ScrollPane;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
import org.jackhuang.hmcl.ui.ListPage;
|
import org.jackhuang.hmcl.ui.ListPage;
|
||||||
@@ -32,8 +28,6 @@ import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
|||||||
import org.jackhuang.hmcl.util.javafx.MappedObservableList;
|
import org.jackhuang.hmcl.util.javafx.MappedObservableList;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
|
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.loadFXML;
|
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.smoothScrolling;
|
|
||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
public class AuthlibInjectorServersPage extends ListPage<AuthlibInjectorServerItem> implements DecoratorPage {
|
public class AuthlibInjectorServersPage extends ListPage<AuthlibInjectorServerItem> implements DecoratorPage {
|
||||||
|
|||||||
@@ -75,9 +75,7 @@ public class JFXCheckBoxTreeTableCell<S,T> extends TreeTableCell<S,T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ObjectProperty<Callback<Integer, ObservableValue<Boolean>>>
|
private ObjectProperty<Callback<Integer, ObservableValue<Boolean>>>
|
||||||
selectedStateCallback =
|
selectedStateCallback = new SimpleObjectProperty<>(this, "selectedStateCallback");
|
||||||
new SimpleObjectProperty<Callback<Integer, ObservableValue<Boolean>>>(
|
|
||||||
this, "selectedStateCallback");
|
|
||||||
|
|
||||||
public final ObjectProperty<Callback<Integer, ObservableValue<Boolean>>> selectedStateCallbackProperty() {
|
public final ObjectProperty<Callback<Integer, ObservableValue<Boolean>>> selectedStateCallbackProperty() {
|
||||||
return selectedStateCallback;
|
return selectedStateCallback;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
|||||||
|
|
||||||
public final class MessageDialogPane extends StackPane {
|
public final class MessageDialogPane extends StackPane {
|
||||||
|
|
||||||
public static enum MessageType {
|
public enum MessageType {
|
||||||
ERROR,
|
ERROR,
|
||||||
INFORMATION,
|
INFORMATION,
|
||||||
WARNING,
|
WARNING,
|
||||||
|
|||||||
@@ -123,16 +123,13 @@ public class DecoratorSkin extends SkinBase<Decorator> {
|
|||||||
{
|
{
|
||||||
StackPane container = new StackPane();
|
StackPane container = new StackPane();
|
||||||
Bindings.bindContent(container.getChildren(), skinnable.containerProperty());
|
Bindings.bindContent(container.getChildren(), skinnable.containerProperty());
|
||||||
ListChangeListener<Node> listener = new ListChangeListener<Node>() {
|
ListChangeListener<Node> listener = c -> {
|
||||||
@Override
|
if (skinnable.getContainer().isEmpty()) {
|
||||||
public void onChanged(Change<? extends Node> c) {
|
container.setMouseTransparent(true);
|
||||||
if (skinnable.getContainer().isEmpty()) {
|
container.setVisible(false);
|
||||||
container.setMouseTransparent(true);
|
} else {
|
||||||
container.setVisible(false);
|
container.setMouseTransparent(false);
|
||||||
} else {
|
container.setVisible(true);
|
||||||
container.setMouseTransparent(false);
|
|
||||||
container.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
skinnable.containerProperty().addListener(listener);
|
skinnable.containerProperty().addListener(listener);
|
||||||
|
|||||||
@@ -98,15 +98,15 @@ public final class InstallerWizardProvider implements WizardProvider {
|
|||||||
Task<Version> ret = Task.supplyAsync(() -> version);
|
Task<Version> ret = Task.supplyAsync(() -> version);
|
||||||
|
|
||||||
if (settings.containsKey("forge"))
|
if (settings.containsKey("forge"))
|
||||||
ret = ret.thenCompose(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get("forge")));
|
ret = ret.thenComposeAsync(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get("forge")));
|
||||||
|
|
||||||
if (settings.containsKey("liteloader"))
|
if (settings.containsKey("liteloader"))
|
||||||
ret = ret.thenCompose(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get("liteloader")));
|
ret = ret.thenComposeAsync(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get("liteloader")));
|
||||||
|
|
||||||
if (settings.containsKey("optifine"))
|
if (settings.containsKey("optifine"))
|
||||||
ret = ret.thenCompose(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get("optifine")));
|
ret = ret.thenComposeAsync(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get("optifine")));
|
||||||
|
|
||||||
return ret.thenCompose(profile.getRepository().refreshVersionsAsync());
|
return ret.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class ModpackInstallWizardProvider implements WizardProvider {
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return ModpackHelper.getInstallTask(profile, selected, name, modpack)
|
return ModpackHelper.getInstallTask(profile, selected, name, modpack)
|
||||||
.thenRun(Schedulers.javafx(), () -> profile.setSelectedVersion(name));
|
.thenRunAsync(Schedulers.javafx(), () -> profile.setSelectedVersion(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public final class ModpackPage extends StackPane implements WizardPage {
|
|||||||
|
|
||||||
spinnerPane.showSpinner();
|
spinnerPane.showSpinner();
|
||||||
Task.supplyAsync(() -> CompressingUtils.findSuitableEncoding(selectedFile.toPath()))
|
Task.supplyAsync(() -> CompressingUtils.findSuitableEncoding(selectedFile.toPath()))
|
||||||
.thenApply(encoding -> manifest = ModpackHelper.readModpackManifest(selectedFile.toPath(), encoding))
|
.thenApplyAsync(encoding -> manifest = ModpackHelper.readModpackManifest(selectedFile.toPath(), encoding))
|
||||||
.whenComplete(Schedulers.javafx(), manifest -> {
|
.whenComplete(Schedulers.javafx(), manifest -> {
|
||||||
spinnerPane.hideSpinner();
|
spinnerPane.hideSpinner();
|
||||||
controller.getSettings().put(MODPACK_MANIFEST, manifest);
|
controller.getSettings().put(MODPACK_MANIFEST, manifest);
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public final class UpdateInstallerWizardProvider implements WizardProvider {
|
|||||||
LinkedList<Library> newList = new LinkedList<>(version.getLibraries());
|
LinkedList<Library> newList = new LinkedList<>(version.getLibraries());
|
||||||
newList.remove(oldLibrary);
|
newList.remove(oldLibrary);
|
||||||
return new MaintainTask(version.setLibraries(newList))
|
return new MaintainTask(version.setLibraries(newList))
|
||||||
.thenCompose(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get(libraryId)))
|
.thenComposeAsync(profile.getDependency().installLibraryAsync((RemoteVersion) settings.get(libraryId)))
|
||||||
.then(profile.getRepository().refreshVersionsAsync());
|
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public final class VanillaInstallWizardProvider implements WizardProvider {
|
|||||||
builder.version((RemoteVersion) settings.get("optifine"));
|
builder.version((RemoteVersion) settings.get("optifine"));
|
||||||
|
|
||||||
return builder.buildAsync().whenComplete(any -> profile.getRepository().refreshVersions())
|
return builder.buildAsync().whenComplete(any -> profile.getRepository().refreshVersions())
|
||||||
.thenRun(Schedulers.javafx(), () -> profile.setSelectedVersion(name));
|
.thenRunAsync(Schedulers.javafx(), () -> profile.setSelectedVersion(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public final class ExportWizardProvider implements WizardProvider {
|
|||||||
), tempModpack);
|
), tempModpack);
|
||||||
|
|
||||||
if (includeLauncher) {
|
if (includeLauncher) {
|
||||||
dependency = dependency.thenRun(() -> {
|
dependency = dependency.thenRunAsync(() -> {
|
||||||
try (Zipper zip = new Zipper(modpackFile.toPath())) {
|
try (Zipper zip = new Zipper(modpackFile.toPath())) {
|
||||||
Config exported = new Config();
|
Config exported = new Config();
|
||||||
|
|
||||||
|
|||||||
@@ -60,17 +60,18 @@ public class DatapackListPage extends ListPageBase<DatapackListPageSkin.Datapack
|
|||||||
|
|
||||||
setItems(items = MappedObservableList.create(datapack.getInfo(), DatapackListPageSkin.DatapackInfoObject::new));
|
setItems(items = MappedObservableList.create(datapack.getInfo(), DatapackListPageSkin.DatapackInfoObject::new));
|
||||||
|
|
||||||
FXUtils.applyDragListener(this, it -> Objects.equals("zip", FileUtils.getExtension(it)), mods -> {
|
FXUtils.applyDragListener(this, it -> Objects.equals("zip", FileUtils.getExtension(it)),
|
||||||
mods.forEach(it -> {
|
mods -> mods.forEach(this::installSingleDatapack), this::refresh);
|
||||||
try {
|
}
|
||||||
Datapack zip = new Datapack(it.toPath());
|
|
||||||
zip.loadFromZip();
|
private void installSingleDatapack(File datapack) {
|
||||||
zip.installTo(worldDir);
|
try {
|
||||||
} catch (IOException | IllegalArgumentException e) {
|
Datapack zip = new Datapack(datapack.toPath());
|
||||||
Logging.LOG.log(Level.WARNING, "Unable to parse datapack file " + it, e);
|
zip.loadFromZip();
|
||||||
}
|
zip.installTo(worldDir);
|
||||||
});
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
}, this::refresh);
|
Logging.LOG.log(Level.WARNING, "Unable to parse datapack file " + datapack, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,8 +81,8 @@ public class DatapackListPage extends ListPageBase<DatapackListPageSkin.Datapack
|
|||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
Task.of(datapack::loadFromDir)
|
Task.runAsync(datapack::loadFromDir)
|
||||||
.with(Task.of(Schedulers.javafx(), () -> setLoading(false)))
|
.withRunAsync(Schedulers.javafx(), () -> setLoading(false))
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,15 +98,7 @@ public class DatapackListPage extends ListPageBase<DatapackListPageSkin.Datapack
|
|||||||
List<File> res = chooser.showOpenMultipleDialog(Controllers.getStage());
|
List<File> res = chooser.showOpenMultipleDialog(Controllers.getStage());
|
||||||
|
|
||||||
if (res != null)
|
if (res != null)
|
||||||
res.forEach(it -> {
|
res.forEach(this::installSingleDatapack);
|
||||||
try {
|
|
||||||
Datapack zip = new Datapack(it.toPath());
|
|
||||||
zip.loadFromZip();
|
|
||||||
zip.installTo(worldDir);
|
|
||||||
} catch (IOException | IllegalArgumentException e) {
|
|
||||||
Logging.LOG.log(Level.WARNING, "Unable to parse datapack file " + it, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
datapack.loadFromDir();
|
datapack.loadFromDir();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,18 +71,18 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
|||||||
this.version = profile.getRepository().getResolvedVersion(versionId);
|
this.version = profile.getRepository().getResolvedVersion(versionId);
|
||||||
this.gameVersion = null;
|
this.gameVersion = null;
|
||||||
|
|
||||||
Task.ofResult(() -> {
|
Task.supplyAsync(() -> {
|
||||||
gameVersion = GameVersion.minecraftVersion(profile.getRepository().getVersionJar(version)).orElse(null);
|
gameVersion = GameVersion.minecraftVersion(profile.getRepository().getVersionJar(version)).orElse(null);
|
||||||
|
|
||||||
return LibraryAnalyzer.analyze(version);
|
return LibraryAnalyzer.analyze(version);
|
||||||
}).thenAccept(Schedulers.javafx(), analyzer -> {
|
}).thenAcceptAsync(Schedulers.javafx(), analyzer -> {
|
||||||
Function<Library, Consumer<InstallerItem>> removeAction = library -> x -> {
|
Function<Library, Consumer<InstallerItem>> removeAction = library -> x -> {
|
||||||
LinkedList<Library> newList = new LinkedList<>(version.getLibraries());
|
LinkedList<Library> newList = new LinkedList<>(version.getLibraries());
|
||||||
newList.remove(library);
|
newList.remove(library);
|
||||||
new MaintainTask(version.setLibraries(newList))
|
new MaintainTask(version.setLibraries(newList))
|
||||||
.thenCompose(maintainedVersion -> new VersionJsonSaveTask(profile.getRepository(), maintainedVersion))
|
.thenComposeAsync(maintainedVersion -> new VersionJsonSaveTask(profile.getRepository(), maintainedVersion))
|
||||||
.withCompose(profile.getRepository().refreshVersionsAsync())
|
.withComposeAsync(profile.getRepository().refreshVersionsAsync())
|
||||||
.withRun(Schedulers.javafx(), () -> loadVersion(this.profile, this.versionId))
|
.withRunAsync(Schedulers.javafx(), () -> loadVersion(this.profile, this.versionId))
|
||||||
.start();
|
.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -118,8 +118,8 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doInstallOffline(File file) {
|
private void doInstallOffline(File file) {
|
||||||
Task task = profile.getDependency().installLibraryAsync(version, file.toPath())
|
Task<?> task = profile.getDependency().installLibraryAsync(version, file.toPath())
|
||||||
.then(profile.getRepository().refreshVersionsAsync());
|
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||||
task.setName(i18n("install.installer.install_offline"));
|
task.setName(i18n("install.installer.install_offline"));
|
||||||
TaskExecutor executor = task.executor(new TaskListener() {
|
TaskExecutor executor = task.executor(new TaskListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -129,9 +129,9 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
|||||||
loadVersion(profile, versionId);
|
loadVersion(profile, versionId);
|
||||||
Controllers.dialog(i18n("install.success"));
|
Controllers.dialog(i18n("install.success"));
|
||||||
} else {
|
} else {
|
||||||
if (executor.getLastException() == null)
|
if (executor.getException() == null)
|
||||||
return;
|
return;
|
||||||
InstallerWizardProvider.alertFailureMessage(executor.getLastException(), null);
|
InstallerWizardProvider.alertFailureMessage(executor.getException(), null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
|
|||||||
// Actually addMod will not throw exceptions because FileChooser has already filtered files.
|
// Actually addMod will not throw exceptions because FileChooser has already filtered files.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).withRun(Schedulers.javafx(), () -> {
|
}).withRunAsync(Schedulers.javafx(), () -> {
|
||||||
List<String> prompt = new LinkedList<>();
|
List<String> prompt = new LinkedList<>();
|
||||||
if (!succeeded.isEmpty())
|
if (!succeeded.isEmpty())
|
||||||
prompt.add(i18n("mods.add.success", String.join(", ", succeeded)));
|
prompt.add(i18n("mods.add.success", String.join(", ", succeeded)));
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
|
|
||||||
FXUtils.smoothScrolling(scroll);
|
FXUtils.smoothScrolling(scroll);
|
||||||
|
|
||||||
Task.supplyAsync(JavaVersion::getJavas).thenAccept(Schedulers.javafx(), list -> {
|
Task.supplyAsync(JavaVersion::getJavas).thenAcceptAsync(Schedulers.javafx(), list -> {
|
||||||
javaItem.loadChildren(list.stream()
|
javaItem.loadChildren(list.stream()
|
||||||
.map(javaVersion -> javaItem.createChildren(javaVersion.getVersion() + i18n("settings.game.java_directory.bit",
|
.map(javaVersion -> javaItem.createChildren(javaVersion.getVersion() + i18n("settings.game.java_directory.bit",
|
||||||
javaVersion.getPlatform().getBit()), javaVersion.getBinary().toString(), javaVersion))
|
javaVersion.getPlatform().getBit()), javaVersion.getBinary().toString(), javaVersion))
|
||||||
@@ -271,7 +271,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
if (versionSetting == null)
|
if (versionSetting == null)
|
||||||
return;
|
return;
|
||||||
Task.supplyAsync(versionSetting::getJavaVersion)
|
Task.supplyAsync(versionSetting::getJavaVersion)
|
||||||
.thenAccept(Schedulers.javafx(), javaVersion -> javaItem.setSubtitle(Optional.ofNullable(javaVersion)
|
.thenAcceptAsync(Schedulers.javafx(), javaVersion -> javaItem.setSubtitle(Optional.ofNullable(javaVersion)
|
||||||
.map(JavaVersion::getBinary).map(Path::toString).orElse("Invalid Java Path")))
|
.map(JavaVersion::getBinary).map(Path::toString).orElse("Invalid Java Path")))
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class WorldListPage extends ListPageBase<WorldListItem> {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
Task
|
Task
|
||||||
.runAsync(() -> gameVersion = GameVersion.minecraftVersion(profile.getRepository().getVersionJar(id)).orElse(null))
|
.runAsync(() -> gameVersion = GameVersion.minecraftVersion(profile.getRepository().getVersionJar(id)).orElse(null))
|
||||||
.thenSupply(() -> World.getWorlds(savesDir).parallel().collect(Collectors.toList()))
|
.thenSupplyAsync(() -> World.getWorlds(savesDir).parallel().collect(Collectors.toList()))
|
||||||
.whenComplete(Schedulers.javafx(), (result, exception) -> {
|
.whenComplete(Schedulers.javafx(), (result, exception) -> {
|
||||||
worlds = result;
|
worlds = result;
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public interface AbstractWizardDisplayer extends WizardDisplayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void handleTask(Map<String, Object> settings, Task<?> task) {
|
default void handleTask(Map<String, Object> settings, Task<?> task) {
|
||||||
TaskExecutor executor = task.withRun(Schedulers.javafx(), this::navigateToSuccess).executor();
|
TaskExecutor executor = task.withRunAsync(Schedulers.javafx(), this::navigateToSuccess).executor();
|
||||||
TaskListPane pane = new TaskListPane();
|
TaskListPane pane = new TaskListPane();
|
||||||
pane.setExecutor(executor);
|
pane.setExecutor(executor);
|
||||||
navigateTo(pane, Navigation.NavigationDirection.FINISH);
|
navigateTo(pane, Navigation.NavigationDirection.FINISH);
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -161,9 +158,7 @@ public final class UpdateHandler {
|
|||||||
commandline.add(JavaVersion.fromCurrentEnvironment().getBinary().toString());
|
commandline.add(JavaVersion.fromCurrentEnvironment().getBinary().toString());
|
||||||
commandline.add("-jar");
|
commandline.add("-jar");
|
||||||
commandline.add(jar.toAbsolutePath().toString());
|
commandline.add(jar.toAbsolutePath().toString());
|
||||||
for (String arg : appArgs) {
|
commandline.addAll(Arrays.asList(appArgs));
|
||||||
commandline.add(arg);
|
|
||||||
}
|
|
||||||
LOG.info("Starting process: " + commandline);
|
LOG.info("Starting process: " + commandline);
|
||||||
new ProcessBuilder(commandline)
|
new ProcessBuilder(commandline)
|
||||||
.directory(Paths.get("").toAbsolutePath().toFile())
|
.directory(Paths.get("").toAbsolutePath().toFile())
|
||||||
@@ -206,11 +201,7 @@ public final class UpdateHandler {
|
|||||||
StackTraceElement element = stacktrace[i];
|
StackTraceElement element = stacktrace[i];
|
||||||
if (Main.class.getName().equals(element.getClassName())) {
|
if (Main.class.getName().equals(element.getClassName())) {
|
||||||
// we've reached the main method
|
// we've reached the main method
|
||||||
if (i + 1 == stacktrace.length) {
|
return i + 1 != stacktrace.length;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.String?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import com.jfoenix.controls.*?>
|
<?import com.jfoenix.controls.*?>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.jfoenix.controls.*?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import javafx.collections.FXCollections?>
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.Image?>
|
<?import javafx.scene.image.Image?>
|
||||||
|
|||||||
@@ -268,7 +268,6 @@ mods.add.success=Successfully added mods %s.
|
|||||||
mods.choose_mod=Choose your mods
|
mods.choose_mod=Choose your mods
|
||||||
mods.enable=Enable
|
mods.enable=Enable
|
||||||
mods.disable=Disable
|
mods.disable=Disable
|
||||||
mods.name=Name
|
|
||||||
mods.remove=Remove
|
mods.remove=Remove
|
||||||
mods.not_modded=You should install a mod loader first (Forge, or LiteLoader)
|
mods.not_modded=You should install a mod loader first (Forge, or LiteLoader)
|
||||||
|
|
||||||
@@ -321,7 +320,7 @@ settings=Game Settings
|
|||||||
|
|
||||||
settings.advanced=Advanced Settings
|
settings.advanced=Advanced Settings
|
||||||
settings.advanced.dont_check_game_completeness=Don't check game completeness
|
settings.advanced.dont_check_game_completeness=Don't check game completeness
|
||||||
settings.advanced.dont_check_jvm_validity=Don't check whether JVM can launch the game or not
|
settings.advanced.dont_check_jvm_validity=Don't check whether JVM can launch the game or not
|
||||||
settings.advanced.game_dir.default=Default (.minecraft/)
|
settings.advanced.game_dir.default=Default (.minecraft/)
|
||||||
settings.advanced.game_dir.independent=Independent (.minecraft/versions/<version name>/, except assets,libraries)
|
settings.advanced.game_dir.independent=Independent (.minecraft/versions/<version name>/, except assets,libraries)
|
||||||
settings.advanced.java_args_default=Default java args: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
settings.advanced.java_args_default=Default java args: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ main_page=主页
|
|||||||
|
|
||||||
message.confirm=提示
|
message.confirm=提示
|
||||||
message.doing=请耐心等待
|
message.doing=请耐心等待
|
||||||
message.downloading=正在下载...
|
message.downloading=正在下载
|
||||||
message.error=错误
|
message.error=错误
|
||||||
message.info=提示
|
message.info=提示
|
||||||
message.success=已完成
|
message.success=已完成
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
.trace { background-color: blue; }
|
.trace { background-color: blue; }
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
var colors = ["fatal", "error", "warn", "info", "debug", "trace"]
|
var colors = ["fatal", "error", "warn", "info", "debug", "trace"];
|
||||||
var limitedLogs = 100;
|
var limitedLogs = 100;
|
||||||
function appendLog(log, level) {
|
function appendLog(log, level) {
|
||||||
var e = document.createElement("div");
|
var e = document.createElement("div");
|
||||||
@@ -78,13 +78,13 @@
|
|||||||
redisplay(c[i]);
|
redisplay(c[i]);
|
||||||
}
|
}
|
||||||
function redisplay(div) {
|
function redisplay(div) {
|
||||||
var flag = false
|
var flag = false;
|
||||||
for (var j = 0; j < colors.length; ++j) {
|
for (var j = 0; j < colors.length; ++j) {
|
||||||
if (div.className == colors[j]) {
|
if (div.className === colors[j]) {
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
div.hidden = div.className != colors[j];
|
div.hidden = div.className !== colors[j];
|
||||||
}
|
}
|
||||||
div.hidden = !flag;
|
div.hidden = !flag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public class AuthlibInjectorDownloader implements AuthlibInjectorArtifactProvide
|
|||||||
|
|
||||||
private static final String LATEST_BUILD_URL = "https://authlib-injector.yushi.moe/artifact/latest.json";
|
private static final String LATEST_BUILD_URL = "https://authlib-injector.yushi.moe/artifact/latest.json";
|
||||||
|
|
||||||
private Path artifactLocation;
|
private final Path artifactLocation;
|
||||||
private Supplier<DownloadProvider> downloadProvider;
|
private final Supplier<DownloadProvider> downloadProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The flag will be reset after application restart.
|
* The flag will be reset after application restart.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public enum TextureModel {
|
|||||||
|
|
||||||
public final String modelName;
|
public final String modelName;
|
||||||
|
|
||||||
private TextureModel(String modelName) {
|
TextureModel(String modelName) {
|
||||||
this.modelName = modelName;
|
this.modelName = modelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
public Task<Version> installLibraryAsync(String gameVersion, Version version, String libraryId, String libraryVersion) {
|
public Task<Version> installLibraryAsync(String gameVersion, Version version, String libraryId, String libraryVersion) {
|
||||||
VersionList<?> versionList = getVersionList(libraryId);
|
VersionList<?> versionList = getVersionList(libraryId);
|
||||||
return versionList.loadAsync(gameVersion, getDownloadProvider())
|
return versionList.loadAsync(gameVersion, getDownloadProvider())
|
||||||
.thenCompose(() -> installLibraryAsync(version, versionList.getVersion(gameVersion, libraryVersion)
|
.thenComposeAsync(() -> installLibraryAsync(version, versionList.getVersion(gameVersion, libraryVersion)
|
||||||
.orElseThrow(() -> new IllegalStateException("Remote library " + libraryId + " has no version " + libraryVersion))));
|
.orElseThrow(() -> new IllegalStateException("Remote library " + libraryId + " has no version " + libraryVersion))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,9 +108,9 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
else
|
else
|
||||||
throw new IllegalArgumentException("Remote library " + libraryVersion + " is unrecognized.");
|
throw new IllegalArgumentException("Remote library " + libraryVersion + " is unrecognized.");
|
||||||
return task
|
return task
|
||||||
.thenCompose(LibrariesUniqueTask::new)
|
.thenComposeAsync(LibrariesUniqueTask::new)
|
||||||
.thenCompose(MaintainTask::new)
|
.thenComposeAsync(MaintainTask::new)
|
||||||
.thenCompose(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
.thenComposeAsync(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,9 +120,7 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
|
|
||||||
public Task installLibraryAsync(Version oldVersion, Path installer) {
|
public Task installLibraryAsync(Version oldVersion, Path installer) {
|
||||||
return Task
|
return Task
|
||||||
.of(() -> {
|
.composeAsync(() -> {
|
||||||
})
|
|
||||||
.thenCompose(() -> {
|
|
||||||
try {
|
try {
|
||||||
return ForgeInstallTask.install(this, oldVersion, installer);
|
return ForgeInstallTask.install(this, oldVersion, installer);
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
@@ -135,8 +133,8 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
|
|
||||||
throw new UnsupportedOperationException("Library cannot be recognized");
|
throw new UnsupportedOperationException("Library cannot be recognized");
|
||||||
})
|
})
|
||||||
.thenCompose(LibrariesUniqueTask::new)
|
.thenComposeAsync(LibrariesUniqueTask::new)
|
||||||
.thenCompose(MaintainTask::new)
|
.thenComposeAsync(MaintainTask::new)
|
||||||
.thenCompose(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
.thenComposeAsync(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,25 +47,25 @@ public class DefaultGameBuilder extends GameBuilder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task<?> buildAsync() {
|
public Task<?> buildAsync() {
|
||||||
return new VersionJsonDownloadTask(gameVersion, dependencyManager).thenCompose(rawJson -> {
|
return new VersionJsonDownloadTask(gameVersion, dependencyManager).thenComposeAsync(rawJson -> {
|
||||||
Version original = JsonUtils.GSON.fromJson(rawJson, Version.class);
|
Version original = JsonUtils.GSON.fromJson(rawJson, Version.class);
|
||||||
Version version = original.setId(name).setJar(null);
|
Version version = original.setId(name).setJar(null);
|
||||||
Task<?> vanillaTask = downloadGameAsync(gameVersion, version).thenCompose(Task.allOf(
|
Task<?> vanillaTask = downloadGameAsync(gameVersion, version).thenComposeAsync(Task.allOf(
|
||||||
new GameAssetDownloadTask(dependencyManager, version, GameAssetDownloadTask.DOWNLOAD_INDEX_FORCIBLY),
|
new GameAssetDownloadTask(dependencyManager, version, GameAssetDownloadTask.DOWNLOAD_INDEX_FORCIBLY),
|
||||||
new GameLibrariesTask(dependencyManager, version) // Game libraries will be downloaded for multiple times partly, this time is for vanilla libraries.
|
new GameLibrariesTask(dependencyManager, version) // Game libraries will be downloaded for multiple times partly, this time is for vanilla libraries.
|
||||||
).withCompose(new VersionJsonSaveTask(dependencyManager.getGameRepository(), version))); // using [with] because download failure here are tolerant.
|
).withComposeAsync(new VersionJsonSaveTask(dependencyManager.getGameRepository(), version))); // using [with] because download failure here are tolerant.
|
||||||
|
|
||||||
Task<Version> libraryTask = vanillaTask.thenSupply(() -> version);
|
Task<Version> libraryTask = vanillaTask.thenSupplyAsync(() -> version);
|
||||||
|
|
||||||
if (toolVersions.containsKey("forge"))
|
if (toolVersions.containsKey("forge"))
|
||||||
libraryTask = libraryTask.thenCompose(libraryTaskHelper(gameVersion, "forge"));
|
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "forge"));
|
||||||
if (toolVersions.containsKey("liteloader"))
|
if (toolVersions.containsKey("liteloader"))
|
||||||
libraryTask = libraryTask.thenCompose(libraryTaskHelper(gameVersion, "liteloader"));
|
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "liteloader"));
|
||||||
if (toolVersions.containsKey("optifine"))
|
if (toolVersions.containsKey("optifine"))
|
||||||
libraryTask = libraryTask.thenCompose(libraryTaskHelper(gameVersion, "optifine"));
|
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "optifine"));
|
||||||
|
|
||||||
for (RemoteVersion remoteVersion : remoteVersions)
|
for (RemoteVersion remoteVersion : remoteVersions)
|
||||||
libraryTask = libraryTask.thenCompose(dependencyManager.installLibraryAsync(remoteVersion));
|
libraryTask = libraryTask.thenComposeAsync(dependencyManager.installLibraryAsync(remoteVersion));
|
||||||
|
|
||||||
return libraryTask;
|
return libraryTask;
|
||||||
}).whenComplete(exception -> {
|
}).whenComplete(exception -> {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public final class CurseCompletionTask extends Task<Void> {
|
|||||||
private final DefaultGameRepository repository;
|
private final DefaultGameRepository repository;
|
||||||
private final ModManager modManager;
|
private final ModManager modManager;
|
||||||
private final String version;
|
private final String version;
|
||||||
private CurseManifest manifest = null;
|
private CurseManifest manifest;
|
||||||
private final List<Task<?>> dependents = new LinkedList<>();
|
private final List<Task<?>> dependents = new LinkedList<>();
|
||||||
private final List<Task<?>> dependencies = new LinkedList<>();
|
private final List<Task<?>> dependencies = new LinkedList<>();
|
||||||
|
|
||||||
|
|||||||
@@ -174,10 +174,8 @@ public class Datapack {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
String name = FileUtils.getName(subDir);
|
String name = FileUtils.getName(subDir);
|
||||||
boolean enabled = true;
|
|
||||||
if (name.endsWith(".disabled")) {
|
if (name.endsWith(".disabled")) {
|
||||||
name = name.substring(0, name.length() - ".disabled".length());
|
name = name.substring(0, name.length() - ".disabled".length());
|
||||||
enabled = false;
|
|
||||||
}
|
}
|
||||||
if (!name.endsWith(".zip"))
|
if (!name.endsWith(".zip"))
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.mod;
|
package org.jackhuang.hmcl.mod;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.util.Lang;
|
import org.jackhuang.hmcl.util.Lang;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
|
||||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
||||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,9 @@ package org.jackhuang.hmcl.mod;
|
|||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jackhuang.hmcl.util.Immutable;
|
import org.jackhuang.hmcl.util.Immutable;
|
||||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
|
||||||
import org.jackhuang.hmcl.util.io.IOUtils;
|
import org.jackhuang.hmcl.util.io.IOUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.file.FileSystem;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies.add(new MaintainTask(version).thenCompose(maintainedVersion -> new VersionJsonSaveTask(repository, maintainedVersion)));
|
dependencies.add(new MaintainTask(version).thenComposeAsync(maintainedVersion -> new VersionJsonSaveTask(repository, maintainedVersion)));
|
||||||
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/" + manifest.getName() + "/minecraft", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)));
|
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/" + manifest.getName() + "/minecraft", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.mod;
|
package org.jackhuang.hmcl.mod;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import com.google.gson.annotations.JsonAdapter;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jackhuang.hmcl.util.Immutable;
|
import org.jackhuang.hmcl.util.Immutable;
|
||||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||||
@@ -28,14 +27,9 @@ import org.jackhuang.hmcl.util.io.IOUtils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
public class PackMcMeta implements Validation {
|
public class PackMcMeta implements Validation {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|||||||
@@ -200,13 +200,13 @@ public abstract class Task<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws InterruptedException if current thread is interrupted
|
* @throws InterruptedException if current thread is interrupted
|
||||||
* @see Thread#isInterrupted
|
* @see Thread#interrupted
|
||||||
*/
|
*/
|
||||||
public void preExecute() throws Exception {}
|
public void preExecute() throws Exception {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws InterruptedException if current thread is interrupted
|
* @throws InterruptedException if current thread is interrupted
|
||||||
* @see Thread#isInterrupted
|
* @see Thread#interrupted
|
||||||
*/
|
*/
|
||||||
public abstract void execute() throws Exception;
|
public abstract void execute() throws Exception;
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ public abstract class Task<T> {
|
|||||||
* {@link Task#isRelyingOnDependencies()} returns true or false.
|
* {@link Task#isRelyingOnDependencies()} returns true or false.
|
||||||
*
|
*
|
||||||
* @throws InterruptedException if current thread is interrupted
|
* @throws InterruptedException if current thread is interrupted
|
||||||
* @see Thread#isInterrupted
|
* @see Thread#interrupted
|
||||||
* @see Task#isDependenciesSucceeded()
|
* @see Task#isDependenciesSucceeded()
|
||||||
*/
|
*/
|
||||||
public void postExecute() throws Exception {}
|
public void postExecute() throws Exception {}
|
||||||
@@ -342,8 +342,8 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the function's return type
|
* @param <U> the function's return type
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <U, E extends Exception> Task<U> thenApply(ExceptionalFunction<T, U, E> fn) {
|
public <U, E extends Exception> Task<U> thenApplyAsync(ExceptionalFunction<T, U, E> fn) {
|
||||||
return thenApply(Schedulers.defaultScheduler(), fn);
|
return thenApplyAsync(Schedulers.defaultScheduler(), fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -356,8 +356,8 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the function's return type
|
* @param <U> the function's return type
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <U, E extends Exception> Task<U> thenApply(Executor executor, ExceptionalFunction<T, U, E> fn) {
|
public <U, E extends Exception> Task<U> thenApplyAsync(Executor executor, ExceptionalFunction<T, U, E> fn) {
|
||||||
return thenApply(getCaller(), executor, fn);
|
return thenApplyAsync(getCaller(), executor, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,7 +371,7 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the function's return type
|
* @param <U> the function's return type
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <U, E extends Exception> Task<U> thenApply(String name, Executor executor, ExceptionalFunction<T, U, E> fn) {
|
public <U, E extends Exception> Task<U> thenApplyAsync(String name, Executor executor, ExceptionalFunction<T, U, E> fn) {
|
||||||
return new UniApply<>(fn).setExecutor(executor).setName(name);
|
return new UniApply<>(fn).setExecutor(executor).setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,8 +384,8 @@ public abstract class Task<T> {
|
|||||||
* returned Task
|
* returned Task
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> thenAccept(ExceptionalConsumer<T, E> action) {
|
public <E extends Exception> Task<Void> thenAcceptAsync(ExceptionalConsumer<T, E> action) {
|
||||||
return thenAccept(Schedulers.defaultScheduler(), action);
|
return thenAcceptAsync(Schedulers.defaultScheduler(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -397,8 +397,8 @@ public abstract class Task<T> {
|
|||||||
* @param executor the executor to use for asynchronous execution
|
* @param executor the executor to use for asynchronous execution
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> thenAccept(Executor executor, ExceptionalConsumer<T, E> action) {
|
public <E extends Exception> Task<Void> thenAcceptAsync(Executor executor, ExceptionalConsumer<T, E> action) {
|
||||||
return thenAccept(getCaller(), executor, action);
|
return thenAcceptAsync(getCaller(), executor, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,8 +411,8 @@ public abstract class Task<T> {
|
|||||||
* @param executor the executor to use for asynchronous execution
|
* @param executor the executor to use for asynchronous execution
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> thenAccept(String name, Executor executor, ExceptionalConsumer<T, E> action) {
|
public <E extends Exception> Task<Void> thenAcceptAsync(String name, Executor executor, ExceptionalConsumer<T, E> action) {
|
||||||
return thenApply(name, executor, result -> {
|
return thenApplyAsync(name, executor, result -> {
|
||||||
action.accept(result);
|
action.accept(result);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -426,8 +426,8 @@ public abstract class Task<T> {
|
|||||||
* returned Task
|
* returned Task
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> thenRun(ExceptionalRunnable<E> action) {
|
public <E extends Exception> Task<Void> thenRunAsync(ExceptionalRunnable<E> action) {
|
||||||
return thenRun(Schedulers.defaultScheduler(), action);
|
return thenRunAsync(Schedulers.defaultScheduler(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -439,8 +439,8 @@ public abstract class Task<T> {
|
|||||||
* @param executor the executor to use for asynchronous execution
|
* @param executor the executor to use for asynchronous execution
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> thenRun(Executor executor, ExceptionalRunnable<E> action) {
|
public <E extends Exception> Task<Void> thenRunAsync(Executor executor, ExceptionalRunnable<E> action) {
|
||||||
return thenRun(getCaller(), executor, action);
|
return thenRunAsync(getCaller(), executor, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,8 +453,8 @@ public abstract class Task<T> {
|
|||||||
* @param executor the executor to use for asynchronous execution
|
* @param executor the executor to use for asynchronous execution
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> thenRun(String name, Executor executor, ExceptionalRunnable<E> action) {
|
public <E extends Exception> Task<Void> thenRunAsync(String name, Executor executor, ExceptionalRunnable<E> action) {
|
||||||
return thenApply(name, executor, ignore -> {
|
return thenApplyAsync(name, executor, ignore -> {
|
||||||
action.run();
|
action.run();
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -468,8 +468,8 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the function's return type
|
* @param <U> the function's return type
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public final <U> Task<U> thenSupply(Callable<U> fn) {
|
public final <U> Task<U> thenSupplyAsync(Callable<U> fn) {
|
||||||
return thenCompose(() -> Task.supplyAsync(fn));
|
return thenComposeAsync(() -> Task.supplyAsync(fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -481,8 +481,8 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the function's return type
|
* @param <U> the function's return type
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public final <U> Task<U> thenSupply(String name, Callable<U> fn) {
|
public final <U> Task<U> thenSupplyAsync(String name, Callable<U> fn) {
|
||||||
return thenCompose(() -> Task.supplyAsync(name, fn));
|
return thenComposeAsync(() -> Task.supplyAsync(name, fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -493,8 +493,8 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the type of the returned Task's result
|
* @param <U> the type of the returned Task's result
|
||||||
* @return the Task
|
* @return the Task
|
||||||
*/
|
*/
|
||||||
public final <U> Task<U> thenCompose(Task<U> other) {
|
public final <U> Task<U> thenComposeAsync(Task<U> other) {
|
||||||
return thenCompose(() -> other);
|
return thenComposeAsync(() -> other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,7 +505,7 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the type of the returned Task's result
|
* @param <U> the type of the returned Task's result
|
||||||
* @return the Task
|
* @return the Task
|
||||||
*/
|
*/
|
||||||
public final <U> Task<U> thenCompose(ExceptionalSupplier<Task<U>, ?> fn) {
|
public final <U> Task<U> thenComposeAsync(ExceptionalSupplier<Task<U>, ?> fn) {
|
||||||
return new UniCompose<>(fn, true);
|
return new UniCompose<>(fn, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,15 +518,15 @@ public abstract class Task<T> {
|
|||||||
* @param <U> the type of the returned Task's result
|
* @param <U> the type of the returned Task's result
|
||||||
* @return the Task
|
* @return the Task
|
||||||
*/
|
*/
|
||||||
public <U, E extends Exception> Task<U> thenCompose(ExceptionalFunction<T, Task<U>, E> fn) {
|
public <U, E extends Exception> Task<U> thenComposeAsync(ExceptionalFunction<T, Task<U>, E> fn) {
|
||||||
return new UniCompose<>(fn, true);
|
return new UniCompose<>(fn, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final <U> Task<U> withCompose(Task<U> other) {
|
public final <U> Task<U> withComposeAsync(Task<U> other) {
|
||||||
return withCompose(() -> other);
|
return withComposeAsync(() -> other);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final <U, E extends Exception> Task<U> withCompose(ExceptionalSupplier<Task<U>, E> fn) {
|
public final <U, E extends Exception> Task<U> withComposeAsync(ExceptionalSupplier<Task<U>, E> fn) {
|
||||||
return new UniCompose<>(fn, false);
|
return new UniCompose<>(fn, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,8 +538,8 @@ public abstract class Task<T> {
|
|||||||
* returned Task
|
* returned Task
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> withRun(ExceptionalRunnable<E> action) {
|
public <E extends Exception> Task<Void> withRunAsync(ExceptionalRunnable<E> action) {
|
||||||
return withRun(Schedulers.defaultScheduler(), action);
|
return withRunAsync(Schedulers.defaultScheduler(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -551,8 +551,8 @@ public abstract class Task<T> {
|
|||||||
* @param executor the executor to use for asynchronous execution
|
* @param executor the executor to use for asynchronous execution
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> withRun(Executor executor, ExceptionalRunnable<E> action) {
|
public <E extends Exception> Task<Void> withRunAsync(Executor executor, ExceptionalRunnable<E> action) {
|
||||||
return withRun(getCaller(), executor, action);
|
return withRunAsync(getCaller(), executor, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -565,7 +565,7 @@ public abstract class Task<T> {
|
|||||||
* @param executor the executor to use for asynchronous execution
|
* @param executor the executor to use for asynchronous execution
|
||||||
* @return the new Task
|
* @return the new Task
|
||||||
*/
|
*/
|
||||||
public <E extends Exception> Task<Void> withRun(String name, Executor executor, ExceptionalRunnable<E> action) {
|
public <E extends Exception> Task<Void> withRunAsync(String name, Executor executor, ExceptionalRunnable<E> action) {
|
||||||
return new UniCompose<>(() -> Task.runAsync(name, executor, action), false);
|
return new UniCompose<>(() -> Task.runAsync(name, executor, action), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ public class Pair<K, V> implements Map.Entry<K, V> {
|
|||||||
private K key;
|
private K key;
|
||||||
private V value;
|
private V value;
|
||||||
|
|
||||||
@Deprecated
|
private Pair(K key, V value) {
|
||||||
public Pair(K key, V value) {
|
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ public final class NetworkUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href="https://github.com/curl/curl/blob/3f7b1bb89f92c13e69ee51b710ac54f775aab320/lib/transfer.c#L1427-L1461">Curl</a>
|
* @see <a href="https://github.com/curl/curl/blob/3f7b1bb89f92c13e69ee51b710ac54f775aab320/lib/transfer.c#L1427-L1461">Curl</a>
|
||||||
* @param location
|
* @param location the url to be URL encoded
|
||||||
* @return
|
* @return encoded URL
|
||||||
*/
|
*/
|
||||||
public static String encodeLocation(String location) {
|
public static String encodeLocation(String location) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -93,11 +93,11 @@ public final class NetworkUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method aims to solve problem when "Location" in stupid server's response is not encoded.
|
* This method is a work-around that aims to solve problem when "Location" in stupid server's response is not encoded.
|
||||||
* @see <a href="https://github.com/curl/curl/issues/473">Issue with libcurl</a>
|
* @see <a href="https://github.com/curl/curl/issues/473">Issue with libcurl</a>
|
||||||
* @param conn
|
* @param conn the stupid http connection.
|
||||||
* @return
|
* @return manually redirected http connection.
|
||||||
* @throws IOException
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public static HttpURLConnection resolveConnection(HttpURLConnection conn) throws IOException {
|
public static HttpURLConnection resolveConnection(HttpURLConnection conn) throws IOException {
|
||||||
int redirect = 0;
|
int redirect = 0;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import javafx.beans.value.ObservableValue;
|
|||||||
*/
|
*/
|
||||||
public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> BindingMapping<?, T> of(ObservableValue<T> property) {
|
public static <T> BindingMapping<?, T> of(ObservableValue<T> property) {
|
||||||
if (property instanceof BindingMapping) {
|
if (property instanceof BindingMapping) {
|
||||||
return (BindingMapping<?, T>) property;
|
return (BindingMapping<?, T>) property;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public final class ExtendedProperties {
|
|||||||
return (ObjectProperty<Boolean>) checkbox.getProperties().computeIfAbsent(
|
return (ObjectProperty<Boolean>) checkbox.getProperties().computeIfAbsent(
|
||||||
PROP_PREFIX + ".checkbox.reservedSelected",
|
PROP_PREFIX + ".checkbox.reservedSelected",
|
||||||
any -> new MappedProperty<>(checkbox, "ext.reservedSelected",
|
any -> new MappedProperty<>(checkbox, "ext.reservedSelected",
|
||||||
checkbox.selectedProperty(), it -> !(boolean) it, it -> !(boolean) it));
|
checkbox.selectedProperty(), it -> !it, it -> !it));
|
||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public enum OperatingSystem {
|
|||||||
return Paths.get(home, "." + folder);
|
return Paths.get(home, "." + folder);
|
||||||
case WINDOWS:
|
case WINDOWS:
|
||||||
String appdata = System.getenv("APPDATA");
|
String appdata = System.getenv("APPDATA");
|
||||||
return Paths.get(Lang.nonNull(appdata, home), "." + folder);
|
return Paths.get(appdata == null ? home : appdata, "." + folder);
|
||||||
case OSX:
|
case OSX:
|
||||||
return Paths.get(home, "Library", "Application Support", folder);
|
return Paths.get(home, "Library", "Application Support", folder);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.junit.Assert;
|
|||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.concurrent.CancellationException;
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@@ -50,12 +49,12 @@ public class TaskTest {
|
|||||||
AtomicBoolean bool = new AtomicBoolean();
|
AtomicBoolean bool = new AtomicBoolean();
|
||||||
boolean success = Task.supplyAsync(() -> {
|
boolean success = Task.supplyAsync(() -> {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}).withRun(() -> {
|
}).withRunAsync(() -> {
|
||||||
bool.set(true);
|
bool.set(true);
|
||||||
}).test();
|
}).test();
|
||||||
|
|
||||||
Assert.assertTrue("Task should success because withRun will ignore previous exception", success);
|
Assert.assertTrue("Task should success because withRunAsync will ignore previous exception", success);
|
||||||
Assert.assertTrue("withRun should be executed", bool.get());
|
Assert.assertTrue("withRunAsync should be executed", bool.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -63,7 +62,7 @@ public class TaskTest {
|
|||||||
new JFXPanel(); // init JavaFX Toolkit
|
new JFXPanel(); // init JavaFX Toolkit
|
||||||
AtomicBoolean flag = new AtomicBoolean();
|
AtomicBoolean flag = new AtomicBoolean();
|
||||||
boolean result = Task.supplyAsync(JavaVersion::fromCurrentEnvironment)
|
boolean result = Task.supplyAsync(JavaVersion::fromCurrentEnvironment)
|
||||||
.thenAccept(Schedulers.javafx(), javaVersion -> {
|
.thenAcceptAsync(Schedulers.javafx(), javaVersion -> {
|
||||||
flag.set(true);
|
flag.set(true);
|
||||||
Assert.assertEquals(javaVersion, JavaVersion.fromCurrentEnvironment());
|
Assert.assertEquals(javaVersion, JavaVersion.fromCurrentEnvironment());
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user