Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Added support for MultiMC json

### Changed
- Changed InstallationModeOptions toString() to be prettier

## [0.7.5] - 2019-10-16

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
import io.github.ImpactDevelopment.installer.setting.InstallationConfig;
import io.github.ImpactDevelopment.installer.target.targets.Forge;
import io.github.ImpactDevelopment.installer.target.targets.ShowJSON;
import io.github.ImpactDevelopment.installer.target.targets.MultiMC;
import io.github.ImpactDevelopment.installer.target.targets.Validate;
import io.github.ImpactDevelopment.installer.target.targets.Vanilla;

import java.util.function.Function;

public enum InstallationModeOptions {
VANILLA(Vanilla::new, true), FORGE(Forge::new, true), VALIDATE(Validate::new, false), SHOWJSON(ShowJSON::new, true) {
@Override
public String toString() {
return "Show JSON";
}
};
VANILLA(Vanilla::new, true),
FORGE(Forge::new, true),
VALIDATE(Validate::new, false),
MULTIMC(MultiMC::new,true),
SHOWJSON(ShowJSON::new, true);

InstallationModeOptions(Function<InstallationConfig, InstallationMode> mode, boolean showInGUI) {
this.mode = mode;
Expand All @@ -59,7 +59,20 @@ public boolean supports(ImpactVersion impact) {
@Override
public String toString() {
// incredibly based code
String name = super.toString();
return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
// this is oof NGL :eyes:
switch (this) {
case VANILLA:
return "Vanilla";
case SHOWJSON:
return "Show Vanilla JSON";
case MULTIMC:
return "Show MultiMC JSON";
case FORGE:
return "Forge";
case VALIDATE:
return "Validate Vanilla version";
default:
return "Unknown";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of Impact Installer.
*
* Copyright (C) 2019 ImpactDevelopment and contributors
*
* See the CONTRIBUTORS.md file for a list of copyright holders
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

package io.github.ImpactDevelopment.installer.target.targets;

import com.google.gson.JsonObject;
import io.github.ImpactDevelopment.installer.Installer;
import io.github.ImpactDevelopment.installer.setting.InstallationConfig;
import io.github.ImpactDevelopment.installer.target.InstallationMode;

import javax.swing.*;

public class MultiMC implements InstallationMode {
private final InstallationConfig config;

public MultiMC(InstallationConfig config) {
this.config = config;
}

@Override
public String apply() {
JsonObject toDisplay = new Vanilla(config).generateMultiMCJsonVersion();
String data = Installer.gson.toJson(toDisplay);
if (Installer.args.noGUI) {
return data;
}
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame(toDisplay.get("version").getAsString());
JTextArea area = new JTextArea();
area.setEditable(true);
area.append(data);
area.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
frame.getContentPane().add(new JScrollPane(area));
frame.setSize(690, 420);
frame.setVisible(true);
});
return "Here is the JSON for MultiMC " + toDisplay.get("version");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ShowJSON(InstallationConfig config) {

@Override
public String apply() {
JsonObject toDisplay = new Vanilla(config).generateJsonVersion();
JsonObject toDisplay = new Vanilla(config).generateVanillaJsonVersion();
String data = Installer.gson.toJson(toDisplay);
if (Installer.args.noGUI) {
return data;
Expand All @@ -53,6 +53,6 @@ public String apply() {
frame.setSize(690, 420);
frame.setVisible(true);
});
return "Here is the JSON for " + toDisplay.get("id");
return "Here is the JSON for Vanilla " + toDisplay.get("id");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Vanilla(InstallationConfig config) {
this.id = version.mcVersion + "-" + version.name + "_" + version.version + prettifiedOptifineVersion().orElse("");
}

public JsonObject generateJsonVersion() {
public JsonObject generateVanillaJsonVersion() {
JsonObject object = new JsonObject();
object.addProperty("id", id);
object.addProperty("type", "release");
Expand All @@ -71,7 +71,23 @@ public JsonObject generateJsonVersion() {
object.addProperty("minimumLauncherVersion", 0);
object.addProperty("mainClass", "net.minecraft.launchwrapper.Launch");
populateArguments(object);
populateLibraries(object);
populateLibraries(object, false);
return object;
}

public JsonObject generateMultiMCJsonVersion() {
JsonObject object = new JsonObject();
JsonArray arrayTweakers = new JsonArray();
arrayTweakers.add("clientapi.load.ClientTweaker");
arrayTweakers.add("baritone.launch.BaritoneTweaker");
object.addProperty("fileID", "me.zero.clarinet.Impact");
object.addProperty("mainClass", "net.minecraft.launchwrapper.Launch");
object.addProperty("mcVersion", version.mcVersion);
object.addProperty("name", "Impact " + version.version);
object.addProperty("order",10);
object.addProperty("version",id);
object.add("+tweakers", arrayTweakers);
populateLibraries(object, true);
return object;
}

Expand All @@ -94,12 +110,16 @@ private void populateArguments(JsonObject object) {
}
}

private void populateLibraries(JsonObject object) {
private void populateLibraries(JsonObject object, boolean multimc) {
JsonArray libraries = new JsonArray();
for (ILibrary lib : version.resolveLibraries(config)) {
populateLib(lib, libraries);
}
object.add("libraries", libraries);
if (multimc) {
object.add("+libraries", libraries);
} else {
object.add("libraries", libraries);
}

populateOptifine(libraries);
}
Expand Down Expand Up @@ -197,7 +217,7 @@ private void installVersionJson() throws IOException {
}
}
System.out.println("Writing to " + directory.resolve(id + ".json"));
Files.write(directory.resolve(id + ".json"), Installer.gson.toJson(generateJsonVersion()).getBytes(StandardCharsets.UTF_8));
Files.write(directory.resolve(id + ".json"), Installer.gson.toJson(generateVanillaJsonVersion()).getBytes(StandardCharsets.UTF_8));
}

private void installProfiles() throws IOException {
Expand Down