Skip to content

Commit

Permalink
Remove the legacy part due to all forge installers are upgraded.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekerZhayard committed Nov 17, 2021
1 parent 3ee6633 commit e0515ed
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 132 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ repositories {
}

dependencies {
compileOnly "com.google.code.gson:gson:2.8.5"
compileOnly "com.google.code.gson:gson:2.8.7"
compileOnly "cpw.mods:modlauncher:8.0.9"
compileOnly "net.minecraftforge:installer:2.1.4"
compileOnly "net.minecraftforge:installer:2.1.9"
compileOnly "net.sf.jopt-simple:jopt-simple:5.0.4"

provided project(":common")
provided project(":legacy")
multirelase project(":jigsaw")
}

Expand Down
2 changes: 1 addition & 1 deletion converter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}

dependencies {
compileOnly "com.google.code.gson:gson:2.8.5"
compileOnly "com.google.code.gson:gson:2.8.7"
provided rootProject
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static JsonObject getJsonFromZip(Path path, String json) {
throw new RuntimeException("The zip file is invalid!");
}
InputStreamReader isr = new InputStreamReader(zf.getInputStream(versionFile), StandardCharsets.UTF_8);
return new JsonParser().parse(isr).getAsJsonObject();
return JsonParser.parseReader(isr).getAsJsonObject();
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -84,7 +84,7 @@ public static JsonObject getJsonFromZip(Path path, String json) {
// Convert mmc-pack.json:
// - Replace Minecraft version
private static JsonObject convertPackJson(String mcVersion) {
JsonObject pack = new JsonParser().parse(new InputStreamReader(Converter.class.getResourceAsStream("/mmc-pack.json"))).getAsJsonObject();
JsonObject pack = JsonParser.parseReader(new InputStreamReader(Converter.class.getResourceAsStream("/mmc-pack.json"))).getAsJsonObject();

for (JsonElement component : getElement(pack, "components").getAsJsonArray()) {
JsonObject componentObject = component.getAsJsonObject();
Expand All @@ -101,7 +101,7 @@ private static JsonObject convertPackJson(String mcVersion) {
// - Add forge-launcher url
// - Replace Minecraft & Forge versions
private static JsonObject convertPatchesJson(JsonObject installer, JsonObject installProfile, String mcVersion, String forgeVersion, StringBuilder wrapperVersion) {
JsonObject patches = new JsonParser().parse(new InputStreamReader(Converter.class.getResourceAsStream("/patches/net.minecraftforge.json"))).getAsJsonObject();
JsonObject patches = JsonParser.parseReader(new InputStreamReader(Converter.class.getResourceAsStream("/patches/net.minecraftforge.json"))).getAsJsonObject();
JsonArray mavenFiles = getElement(patches, "mavenFiles").getAsJsonArray();
JsonArray libraries = getElement(patches, "libraries").getAsJsonArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"mavenFiles": [
{
"name": "net.minecraftforge:forge:{VERSION}-{FORGE_VERSION}:installer",
"url": "https://files.minecraftforge.net/maven/"
"url": "https://maven.minecraftforge.net/"
}
],
"libraries": [
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

org.gradle.daemon = false

fw_version = 1.5.2
fw_version = 1.5.3
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public static void addOpens(List<String> opens) {
TypeToAdd.OPENS.implAdd(opens);
}

public static ClassLoader getPlatformClassLoader() {
return ClassLoader.getPlatformClassLoader();
}

private enum TypeToAdd {
EXPORTS("Exports"),
OPENS("Opens");
Expand Down
17 changes: 0 additions & 17 deletions legacy/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ rootProject.name = 'ForgeWrapper'
include 'common'
include 'converter'
include 'jigsaw'
include 'legacy'
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.io.File;

import io.github.zekerzhayard.forgewrapper.installer.util.InstallerUtil;
import net.minecraftforge.installer.actions.ProgressCallback;
import net.minecraftforge.installer.json.Install;
import net.minecraftforge.installer.json.Util;

public class Installer {
public static boolean install(File libraryDir, File minecraftJar, File installerJar, String forgeVersion) {
ProgressCallback monitor = ProgressCallback.withOutputs(System.out);
Install install = InstallerUtil.loadInstallProfile(forgeVersion);
Install profile = Util.loadInstallProfile();
if (System.getProperty("java.net.preferIPv4Stack") == null) {
System.setProperty("java.net.preferIPv4Stack", "true");
}
Expand All @@ -18,6 +18,6 @@ public static boolean install(File libraryDir, File minecraftJar, File installer
String jvmVersion = System.getProperty("java.vm.version", "missing jvm version");
monitor.message(String.format("JVM info: %s - %s - %s", vendor, javaVersion, jvmVersion));
monitor.message("java.net.preferIPv4Stack=" + System.getProperty("java.net.preferIPv4Stack"));
return InstallerUtil.runClientInstall(forgeVersion, install, monitor, libraryDir, minecraftJar, installerJar);
return new ClientInstall4MultiMC(profile, monitor, libraryDir, minecraftJar).run(null, input -> true, installerJar);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ public static void main(String[] args) throws Throwable {
String forgeFullVersion = mcVersion + "-" + forgeVersion;

IFileDetector detector = DetectorLoader.loadDetector();
Bootstrap.bootstrap(detector.getJvmArgs(forgeFullVersion), detector.getMinecraftJar(mcVersion).getFileName().toString(), detector.getLibraryDir().toAbsolutePath().toString());
try {
Bootstrap.bootstrap(detector.getJvmArgs(forgeFullVersion), detector.getMinecraftJar(mcVersion).getFileName().toString(), detector.getLibraryDir().toAbsolutePath().toString());
} catch (Throwable ignored) {
// Avoid this bunch of hacks that nuke the whole wrapper.
}
if (!detector.checkExtraFiles(forgeFullVersion)) {
System.out.println("Some extra libraries are missing! Run the installer to generate them now.");
System.out.println("Some extra libraries are missing! Running the installer to generate them now.");

// Check installer jar.
Path installerJar = detector.getInstallerJar(forgeFullVersion);
Expand All @@ -41,7 +45,7 @@ public static void main(String[] args) throws Throwable {
Main.class.getProtectionDomain().getCodeSource().getLocation(),
Launcher.class.getProtectionDomain().getCodeSource().getLocation(),
installerJar.toUri().toURL()
}, getParentClassLoader())) {
}, ModuleUtil.getPlatformClassLoader())) {
Class<?> installer = ucl.loadClass("io.github.zekerzhayard.forgewrapper.installer.Installer");
if (!(boolean) installer.getMethod("install", File.class, File.class, File.class, String.class).invoke(null, detector.getLibraryDir().toFile(), minecraftJar.toFile(), installerJar.toFile(), forgeVersion)) {
return;
Expand All @@ -52,16 +56,4 @@ public static void main(String[] args) throws Throwable {
Class<?> mainClass = ModuleUtil.setupBootstrapLauncher(Class.forName(detector.getMainClass(forgeFullVersion)));
mainClass.getMethod("main", String[].class).invoke(null, new Object[] { args });
}

// https://github.com/MinecraftForge/Installer/blob/fe18a164b5ebb15b5f8f33f6a149cc224f446dc2/src/main/java/net/minecraftforge/installer/actions/PostProcessors.java#L287-L303
private static ClassLoader getParentClassLoader() {
if (!System.getProperty("java.version").startsWith("1.")) {
try {
return (ClassLoader) ClassLoader.class.getDeclaredMethod("getPlatformClassLoader").invoke(null);
} catch (Exception e) {
System.out.println("No platform classloader: " + System.getProperty("java.version"));
}
}
return null;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public static Class<?> setupBootstrapLauncher(Class<?> mainClass) {
// nothing to do with Java 8
return mainClass;
}

public static ClassLoader getPlatformClassLoader() {
// PlatformClassLoader does not exist in Java 8
return null;
}
}

0 comments on commit e0515ed

Please sign in to comment.