Reland: create modpack with launcher packed in
This commit is contained in:
@@ -3,7 +3,6 @@ package org.jackhuang.hmcl.mod;
|
||||
import org.jackhuang.hmcl.mod.mcbbs.McbbsModpackManifest;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -28,7 +27,6 @@ public class ModpackExportInfo {
|
||||
|
||||
private String authlibInjectorServer;
|
||||
|
||||
private Path output;
|
||||
private List<McbbsModpackManifest.Origin> origins = new ArrayList<>();
|
||||
|
||||
public ModpackExportInfo() {}
|
||||
@@ -178,15 +176,6 @@ public class ModpackExportInfo {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Path getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public ModpackExportInfo setOutput(Path output) {
|
||||
this.output = output;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<McbbsModpackManifest.Origin> getOrigins() {
|
||||
return Collections.unmodifiableList(origins);
|
||||
}
|
||||
@@ -198,8 +187,6 @@ public class ModpackExportInfo {
|
||||
}
|
||||
|
||||
public ModpackExportInfo validate() throws NullPointerException {
|
||||
if (output == null)
|
||||
throw new NullPointerException("ModpackExportInfo.output cannot be null");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,16 @@ public class McbbsModpackExportTask extends Task<Void> {
|
||||
private final DefaultGameRepository repository;
|
||||
private final String version;
|
||||
private final ModpackExportInfo info;
|
||||
private final File modpackFile;
|
||||
|
||||
public McbbsModpackExportTask(DefaultGameRepository repository, String version, ModpackExportInfo info) {
|
||||
public McbbsModpackExportTask(DefaultGameRepository repository, String version, ModpackExportInfo info, File modpackFile) {
|
||||
this.repository = repository;
|
||||
this.version = version;
|
||||
this.info = info.validate();
|
||||
this.modpackFile = modpackFile;
|
||||
|
||||
onDone().register(event -> {
|
||||
if (event.isFailed()) this.info.getOutput().toFile().delete();
|
||||
if (event.isFailed()) modpackFile.delete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,7 +64,7 @@ public class McbbsModpackExportTask extends Task<Void> {
|
||||
blackList.add(version + ".jar");
|
||||
blackList.add(version + ".json");
|
||||
Logging.LOG.info("Compressing game files without some files in blacklist, including files or directories: usernamecache.json, asm, logs, backups, versions, assets, usercache.json, libraries, crash-reports, launcher_profiles.json, NVIDIA, TCNodeTracker");
|
||||
try (Zipper zip = new Zipper(info.getOutput())) {
|
||||
try (Zipper zip = new Zipper(modpackFile.toPath())) {
|
||||
Path runDirectory = repository.getRunDirectory(version).toPath();
|
||||
List<McbbsModpackManifest.File> files = new ArrayList<>();
|
||||
zip.putDirectory(runDirectory, "overrides", path -> {
|
||||
|
||||
@@ -45,14 +45,16 @@ public class ServerModpackExportTask extends Task<Void> {
|
||||
private final DefaultGameRepository repository;
|
||||
private final String versionId;
|
||||
private final ModpackExportInfo exportInfo;
|
||||
private final File modpackFile;
|
||||
|
||||
public ServerModpackExportTask(DefaultGameRepository repository, String version, ModpackExportInfo exportInfo) {
|
||||
public ServerModpackExportTask(DefaultGameRepository repository, String version, ModpackExportInfo exportInfo, File modpackFile) {
|
||||
this.repository = repository;
|
||||
this.versionId = version;
|
||||
this.exportInfo = exportInfo.validate();
|
||||
this.modpackFile = modpackFile;
|
||||
|
||||
onDone().register(event -> {
|
||||
if (event.isFailed()) exportInfo.getOutput().toFile().delete();
|
||||
if (event.isFailed()) modpackFile.delete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,7 +64,7 @@ public class ServerModpackExportTask extends Task<Void> {
|
||||
blackList.add(versionId + ".jar");
|
||||
blackList.add(versionId + ".json");
|
||||
Logging.LOG.info("Compressing game files without some files in blacklist, including files or directories: usernamecache.json, asm, logs, backups, versions, assets, usercache.json, libraries, crash-reports, launcher_profiles.json, NVIDIA, TCNodeTracker");
|
||||
try (Zipper zip = new Zipper(exportInfo.getOutput())) {
|
||||
try (Zipper zip = new Zipper(modpackFile.toPath())) {
|
||||
Path runDirectory = repository.getRunDirectory(versionId).toPath();
|
||||
List<ModpackConfiguration.FileInformation> files = new ArrayList<>();
|
||||
zip.putDirectory(runDirectory, "overrides", path -> {
|
||||
|
||||
Reference in New Issue
Block a user