mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-30 13:13:58 +01:00
Start implementing experimental curse plugin
This commit is contained in:
parent
be299164de
commit
a48dbf8ed9
@ -415,7 +415,7 @@ public class PackageBuilder implements Builder {
|
||||
// Load plugins
|
||||
BuilderPluginLoader pluginLoader = new BuilderPluginLoader();
|
||||
pluginLoader.loadClasses(options.getPluginClasses());
|
||||
pluginLoader.dispatchAcceptOptions(args);
|
||||
pluginLoader.dispatchAcceptOptions(options, args);
|
||||
|
||||
Manifest manifest = new Manifest();
|
||||
manifest.setMinimumVersion(Manifest.MIN_PROTOCOL_VERSION);
|
||||
@ -442,7 +442,7 @@ public class PackageBuilder implements Builder {
|
||||
builder.addLoaders(options.getLoadersDir(), options.getLibrariesDir());
|
||||
builder.downloadLibraries(options.getLibrariesDir());
|
||||
|
||||
pluginLoader.dispatchBuilderFinished(builder);
|
||||
pluginLoader.dispatchBuild(builder);
|
||||
|
||||
builder.writeManifest(options.getManifestPath());
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.skcraft.launcher.builder.curse;
|
||||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.skcraft.launcher.builder.BuilderOptions;
|
||||
import com.skcraft.launcher.builder.plugin.Builder;
|
||||
import com.skcraft.launcher.builder.plugin.BuilderPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CurseBuildPlugin extends BuilderPlugin {
|
||||
private CurseOptions options = new CurseOptions();
|
||||
|
||||
@Override
|
||||
public void acceptOptions(BuilderOptions builderOptions, String[] args) {
|
||||
new JCommander(this.options, args);
|
||||
|
||||
if (options.getCachePath() == null) {
|
||||
options.setCachePath(new File(builderOptions.getInputPath(), "cache"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBuild(Builder builder) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.skcraft.launcher.builder.curse;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Data
|
||||
public class CurseOptions {
|
||||
@Parameter(names = "--cache", description = "Path to cache folder where downloaded artifacts are stored.")
|
||||
private File cachePath;
|
||||
|
||||
@Parameter(names = "--import-curse-manifest", description = "Import mods and loaders from a Curse manifest JSON")
|
||||
private File curseManifestLocation;
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package com.skcraft.launcher.builder.plugin;
|
||||
|
||||
import com.skcraft.launcher.builder.BuilderOptions;
|
||||
import com.skcraft.launcher.model.modpack.Manifest;
|
||||
|
||||
/**
|
||||
* Class that all builder plugins should extend.
|
||||
*/
|
||||
public abstract class BuilderPlugin {
|
||||
public void acceptOptions(String[] args) {}
|
||||
public void acceptOptions(BuilderOptions options, String[] args) {}
|
||||
public void onManifestCreated(Manifest manifest) {}
|
||||
public void onBuilderFinished(Builder builder) {}
|
||||
public void onBuild(Builder builder) {}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.skcraft.launcher.builder.plugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.skcraft.launcher.builder.BuilderOptions;
|
||||
import com.skcraft.launcher.model.modpack.Manifest;
|
||||
import lombok.extern.java.Log;
|
||||
|
||||
@ -48,9 +49,9 @@ public class BuilderPluginLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void dispatchAcceptOptions(String[] args) {
|
||||
public void dispatchAcceptOptions(BuilderOptions options, String[] args) {
|
||||
for (BuilderPlugin plugin : loadedPlugins) {
|
||||
plugin.acceptOptions(args);
|
||||
plugin.acceptOptions(options, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,9 +61,9 @@ public class BuilderPluginLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchBuilderFinished(Builder builder) {
|
||||
public void dispatchBuild(Builder builder) {
|
||||
for (BuilderPlugin plugin : loadedPlugins) {
|
||||
plugin.onBuilderFinished(builder);
|
||||
plugin.onBuild(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user