mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-28 12:57:07 +01:00
Added launch modifier to packages.
This commit is contained in:
parent
fc964d0d66
commit
79bbc9c252
@ -7,6 +7,9 @@
|
|||||||
package com.skcraft.launcher;
|
package com.skcraft.launcher;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.skcraft.launcher.launch.JavaProcessBuilder;
|
||||||
|
import com.skcraft.launcher.model.modpack.LaunchModifier;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -22,6 +25,8 @@ public class Instance implements Comparable<Instance> {
|
|||||||
private boolean updatePending;
|
private boolean updatePending;
|
||||||
private boolean installed;
|
private boolean installed;
|
||||||
private Date lastAccessed;
|
private Date lastAccessed;
|
||||||
|
@JsonProperty("launch")
|
||||||
|
private LaunchModifier launchModifier;
|
||||||
|
|
||||||
@JsonIgnore private File dir;
|
@JsonIgnore private File dir;
|
||||||
@JsonIgnore private URL manifestURL;
|
@JsonIgnore private URL manifestURL;
|
||||||
@ -33,6 +38,12 @@ public class Instance implements Comparable<Instance> {
|
|||||||
return title != null ? title : name;
|
return title != null ? title : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void modify(JavaProcessBuilder builder) {
|
||||||
|
if (launchModifier != null) {
|
||||||
|
launchModifier.modify(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public File getContentDir() {
|
public File getContentDir() {
|
||||||
return new File(dir, "minecraft");
|
return new File(dir, "minecraft");
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
package com.skcraft.launcher.builder;
|
package com.skcraft.launcher.builder;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.skcraft.launcher.model.modpack.LaunchModifier;
|
||||||
|
import com.skcraft.launcher.model.modpack.Manifest;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,9 +22,18 @@ public class BuilderConfig {
|
|||||||
private String name;
|
private String name;
|
||||||
private String title;
|
private String title;
|
||||||
private String gameVersion;
|
private String gameVersion;
|
||||||
|
@JsonProperty("launch")
|
||||||
|
private LaunchModifier launchModifier;
|
||||||
private List<FeaturePattern> features;
|
private List<FeaturePattern> features;
|
||||||
private FnPatternList userFiles;
|
private FnPatternList userFiles;
|
||||||
|
|
||||||
|
public void update(Manifest manifest) {
|
||||||
|
manifest.updateName(getName());
|
||||||
|
manifest.updateTitle(getTitle());
|
||||||
|
manifest.updateGameVersion(getGameVersion());
|
||||||
|
manifest.setLaunchModifier(getLaunchModifier());
|
||||||
|
}
|
||||||
|
|
||||||
public void registerProperties(PropertiesApplicator applicator) {
|
public void registerProperties(PropertiesApplicator applicator) {
|
||||||
if (features != null) {
|
if (features != null) {
|
||||||
for (FeaturePattern feature : features) {
|
for (FeaturePattern feature : features) {
|
||||||
|
@ -79,9 +79,7 @@ public class PackageBuilder {
|
|||||||
public void readConfig(File path) throws IOException {
|
public void readConfig(File path) throws IOException {
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
BuilderConfig config = read(path, BuilderConfig.class);
|
BuilderConfig config = read(path, BuilderConfig.class);
|
||||||
manifest.updateName(config.getName());
|
config.update(manifest);
|
||||||
manifest.updateTitle(config.getTitle());
|
|
||||||
manifest.updateGameVersion(config.getGameVersion());
|
|
||||||
config.registerProperties(applicator);
|
config.registerProperties(applicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class Runner implements Callable<Process>, ProgressObservable {
|
|||||||
builder = new JavaProcessBuilder();
|
builder = new JavaProcessBuilder();
|
||||||
assetsRoot = launcher.getAssets();
|
assetsRoot = launcher.getAssets();
|
||||||
|
|
||||||
// Load versionManifest and assets index
|
// Load manifiests
|
||||||
versionManifest = mapper.readValue(instance.getVersionPath(), VersionManifest.class);
|
versionManifest = mapper.readValue(instance.getVersionPath(), VersionManifest.class);
|
||||||
|
|
||||||
// Load assets index
|
// Load assets index
|
||||||
@ -141,6 +141,8 @@ public class Runner implements Callable<Process>, ProgressObservable {
|
|||||||
builder.classPath(getJarPath());
|
builder.classPath(getJarPath());
|
||||||
builder.setMainClass(versionManifest.getMainClass());
|
builder.setMainClass(versionManifest.getMainClass());
|
||||||
|
|
||||||
|
callLaunchModifier();
|
||||||
|
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(builder.buildCommand());
|
ProcessBuilder processBuilder = new ProcessBuilder(builder.buildCommand());
|
||||||
processBuilder.directory(instance.getContentDir());
|
processBuilder.directory(instance.getContentDir());
|
||||||
Runner.log.info("Launching: " + builder);
|
Runner.log.info("Launching: " + builder);
|
||||||
@ -151,6 +153,13 @@ public class Runner implements Callable<Process>, ProgressObservable {
|
|||||||
return processBuilder.start();
|
return processBuilder.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the manifest launch modifier.
|
||||||
|
*/
|
||||||
|
private void callLaunchModifier() {
|
||||||
|
instance.modify(builder);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add platform-specific arguments.
|
* Add platform-specific arguments.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* SK's Minecraft Launcher
|
||||||
|
* Copyright (C) 2010-2014 Albert Pham <http://www.sk89q.com> and contributors
|
||||||
|
* Please see LICENSE.txt for license information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.skcraft.launcher.model.modpack;
|
||||||
|
|
||||||
|
import com.skcraft.launcher.launch.JavaProcessBuilder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LaunchModifier {
|
||||||
|
|
||||||
|
private List<String> flags;
|
||||||
|
|
||||||
|
public void modify(JavaProcessBuilder builder) {
|
||||||
|
if (flags != null) {
|
||||||
|
for (String flag : flags) {
|
||||||
|
builder.getFlags().add(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,9 @@ package com.skcraft.launcher.model.modpack;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.skcraft.launcher.Instance;
|
||||||
import com.skcraft.launcher.LauncherUtils;
|
import com.skcraft.launcher.LauncherUtils;
|
||||||
import com.skcraft.launcher.model.minecraft.VersionManifest;
|
import com.skcraft.launcher.model.minecraft.VersionManifest;
|
||||||
import com.skcraft.launcher.install.Installer;
|
import com.skcraft.launcher.install.Installer;
|
||||||
@ -30,6 +32,8 @@ public class Manifest extends BaseManifest {
|
|||||||
private String librariesLocation;
|
private String librariesLocation;
|
||||||
private String objectsLocation;
|
private String objectsLocation;
|
||||||
private String gameVersion;
|
private String gameVersion;
|
||||||
|
@JsonProperty("launch")
|
||||||
|
private LaunchModifier launchModifier;
|
||||||
private List<Feature> features = new ArrayList<Feature>();
|
private List<Feature> features = new ArrayList<Feature>();
|
||||||
@JsonManagedReference("manifest")
|
@JsonManagedReference("manifest")
|
||||||
private List<ManifestEntry> tasks = new ArrayList<ManifestEntry>();
|
private List<ManifestEntry> tasks = new ArrayList<ManifestEntry>();
|
||||||
@ -80,4 +84,8 @@ public class Manifest extends BaseManifest {
|
|||||||
setGameVersion(gameVersion);
|
setGameVersion(gameVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(Instance instance) {
|
||||||
|
instance.setLaunchModifier(getLaunchModifier());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,9 @@ public class Updater extends BaseUpdater implements Callable<Instance>, Progress
|
|||||||
progress = new DefaultProgress(-1, _("instanceUpdater.readingManifest"));
|
progress = new DefaultProgress(-1, _("instanceUpdater.readingManifest"));
|
||||||
Manifest manifest = installPackage(installer, instance);
|
Manifest manifest = installPackage(installer, instance);
|
||||||
|
|
||||||
|
// Update instance from manifest
|
||||||
|
manifest.update(instance);
|
||||||
|
|
||||||
// Read version manifest
|
// Read version manifest
|
||||||
log.info("Reading version manifest...");
|
log.info("Reading version manifest...");
|
||||||
progress = new DefaultProgress(-1, _("instanceUpdater.readingVersion"));
|
progress = new DefaultProgress(-1, _("instanceUpdater.readingVersion"));
|
||||||
|
Loading…
Reference in New Issue
Block a user