Skip to content

Commit

Permalink
actually create the launcher profile
Browse files Browse the repository at this point in the history
  • Loading branch information
leijurv committed May 23, 2019
1 parent f7d0ab0 commit 2f6c0d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/main/java/io/github/ImpactDevelopment/installer/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
import com.google.gson.GsonBuilder;
import io.github.ImpactDevelopment.installer.gui.AppIcon;
import io.github.ImpactDevelopment.installer.gui.AppWindow;
import io.github.ImpactDevelopment.installer.impact.ImpactJsonVersion;
import io.github.ImpactDevelopment.installer.profiles.VanillaProfiles;
import io.github.ImpactDevelopment.installer.setting.InstallationConfig;
import io.github.ImpactDevelopment.installer.setting.settings.ImpactVersionSetting;
import io.github.ImpactDevelopment.installer.versions.Vanilla;
import org.apache.commons.io.IOUtils;

import javax.swing.*;
Expand Down Expand Up @@ -64,26 +59,6 @@ public static void main(String... args) throws Throwable {
SwingUtilities.invokeLater(AppWindow::new);
}

public static void install(InstallationConfig config) throws Exception { // really anything can happen lol
ImpactJsonVersion version = config.getSettingValue(ImpactVersionSetting.INSTANCE).fetchContents();
Vanilla vanilla = new Vanilla(config);
System.out.println("Installing impact " + vanilla.getId());
System.out.println("Info:");
version.printInfo();

System.out.println("Creating vanilla version");

vanilla.apply();

System.out.println("Loading existing vanilla profiles");
VanillaProfiles profiles = new VanillaProfiles(config);
System.out.println("Injecting impact version...");

profiles.addOrMutate(version.name + " " + version.version + " for " + version.mcVersion, vanilla.getId());
System.out.println("Saving vanilla profiles");
profiles.saveToDisk();
}

public static String getTitle() {
return project + " Installer";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.github.ImpactDevelopment.installer.impact.ImpactJsonVersion;
import io.github.ImpactDevelopment.installer.libraries.ILibrary;
import io.github.ImpactDevelopment.installer.libraries.MavenResolver;
import io.github.ImpactDevelopment.installer.profiles.VanillaProfiles;
import io.github.ImpactDevelopment.installer.setting.InstallationConfig;
import io.github.ImpactDevelopment.installer.setting.settings.ImpactVersionSetting;
import io.github.ImpactDevelopment.installer.setting.settings.MinecraftDirectorySetting;
Expand Down Expand Up @@ -122,6 +123,15 @@ public static void populateLib(ILibrary lib, JsonArray libraries) {

@Override
public void apply() throws IOException {
System.out.println("Installing impact " + getId());
System.out.println("Info:");
version.printInfo();
installVersionJson();
installProfiles();
}

private void installVersionJson() throws IOException {
System.out.println("Creating vanilla version");
Path directory = config.getSettingValue(MinecraftDirectorySetting.INSTANCE).resolve("versions").resolve(id);
if (!Files.exists(directory)) {
try {
Expand All @@ -134,6 +144,16 @@ public void apply() throws IOException {
Files.write(directory.resolve(id + ".json"), Installer.gson.toJson(populate()).getBytes(StandardCharsets.UTF_8));
}

private void installProfiles() throws IOException {
System.out.println("Loading existing vanilla profiles");
VanillaProfiles profiles = new VanillaProfiles(config);
System.out.println("Injecting impact version...");

profiles.addOrMutate(version.name + " " + version.version + " for " + version.mcVersion, getId());
System.out.println("Saving vanilla profiles");
profiles.saveToDisk();
}

public String getId() {
return id;
}
Expand Down

0 comments on commit 2f6c0d1

Please sign in to comment.