Skip installing forge while extract files exist.
This commit is contained in:
parent
c04ad2e036
commit
812a810acc
5 changed files with 35 additions and 34 deletions
|
@ -5,7 +5,7 @@ apply plugin: "idea"
|
|||
|
||||
sourceCompatibility = targetCompatibility = 1.8
|
||||
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
group = "io.github.zekerzhayard"
|
||||
archivesBaseName = rootProject.name
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package io.github.zekerzhayard.forgewrapper.installer;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import cpw.mods.modlauncher.Launcher;
|
||||
import net.minecraftforge.installer.actions.ActionCanceledException;
|
||||
import net.minecraftforge.installer.actions.ClientInstall;
|
||||
import net.minecraftforge.installer.actions.ProgressCallback;
|
||||
|
@ -17,15 +15,7 @@ public class ClientInstall4MultiMC extends ClientInstall {
|
|||
|
||||
@Override
|
||||
public boolean run(File target, Predicate<String> optionals) {
|
||||
File librariesDir;
|
||||
try {
|
||||
File laucnher = new File(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||
// see https://github.com/MinecraftForge/MinecraftForge/blob/863ab2ca184cf2e2dfa134d07bfc20d6a9a6a4e8/src/main/java/net/minecraftforge/fml/relauncher/libraries/LibraryManager.java#L151
|
||||
// /<version> /modlauncher /mods /cpw /libraries
|
||||
librariesDir = laucnher.getParentFile().getParentFile().getParentFile().getParentFile().getParentFile();
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
File librariesDir = Main.getLibrariesDir();
|
||||
File clientTarget = new File(String.format("%s/com/mojang/minecraft/%s/minecraft-%s-client.jar", librariesDir.getAbsolutePath(), this.profile.getMinecraft(), this.profile.getMinecraft()));
|
||||
|
||||
boolean downloadLibraries = true; // Force true when without an internet connection.
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package io.github.zekerzhayard.forgewrapper.installer;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -14,21 +17,38 @@ public class Main {
|
|||
public static void main(String[] args) throws Exception {
|
||||
List<String> argsList = Stream.of(args).collect(Collectors.toList());
|
||||
String version = argsList.get(argsList.indexOf("--fml.mcVersion") + 1) + "-" + argsList.get(argsList.indexOf("--fml.forgeVersion") + 1);
|
||||
String installerUrl = String.format("https://files.minecraftforge.net/maven/net/minecraftforge/forge/%s/forge-%s-installer.jar", version, version);
|
||||
String installerFileStr = String.format("./.forgewrapper/forge-%s-installer.jar", version);
|
||||
Utils.download(installerUrl, installerFileStr);
|
||||
|
||||
URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {
|
||||
Main.class.getProtectionDomain().getCodeSource().getLocation(),
|
||||
Launcher.class.getProtectionDomain().getCodeSource().getLocation(),
|
||||
new File(installerFileStr).toURI().toURL()
|
||||
}, null);
|
||||
Path forgeDir = getLibrariesDir().toPath().resolve("net").resolve("minecraftforge").resolve("forge").resolve(version);
|
||||
Path clientJar = forgeDir.resolve("forge-" + version + "-client.jar");
|
||||
Path extraJar = forgeDir.resolve("forge-" + version + "-extra.jar");
|
||||
if (Files.exists(clientJar) && Files.exists(extraJar)) {
|
||||
String installerUrl = String.format("https://files.minecraftforge.net/maven/net/minecraftforge/forge/%s/forge-%s-installer.jar", version, version);
|
||||
String installerFileStr = String.format("./.forgewrapper/forge-%s-installer.jar", version);
|
||||
Utils.download(installerUrl, installerFileStr);
|
||||
|
||||
Class<?> installer = ucl.loadClass("io.github.zekerzhayard.forgewrapper.installer.Installer");
|
||||
if (!(boolean) installer.getMethod("install").invoke(null)) {
|
||||
return;
|
||||
URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {
|
||||
Main.class.getProtectionDomain().getCodeSource().getLocation(),
|
||||
Launcher.class.getProtectionDomain().getCodeSource().getLocation(),
|
||||
new File(installerFileStr).toURI().toURL()
|
||||
}, null);
|
||||
|
||||
Class<?> installer = ucl.loadClass("io.github.zekerzhayard.forgewrapper.installer.Installer");
|
||||
if (!(boolean) installer.getMethod("install").invoke(null)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Launcher.main(args);
|
||||
}
|
||||
|
||||
public static File getLibrariesDir() {
|
||||
try {
|
||||
File laucnher = new File(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||
// see https://github.com/MinecraftForge/MinecraftForge/blob/863ab2ca184cf2e2dfa134d07bfc20d6a9a6a4e8/src/main/java/net/minecraftforge/fml/relauncher/libraries/LibraryManager.java#L151
|
||||
// /<version> /modlauncher /mods /cpw /libraries
|
||||
return laucnher.getParentFile().getParentFile().getParentFile().getParentFile().getParentFile();
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package why.does.multimc.target;
|
||||
|
||||
import io.github.zekerzhayard.forgewrapper.installer.Main;
|
||||
|
||||
public class Me {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Main.main(args);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"formatVersion": 1,
|
||||
"mainClass": "why.does.multimc.target.Me",
|
||||
"mainClass": "io.github.zekerzhayard.forgewrapper.installer.Main",
|
||||
"minecraftArguments": "",
|
||||
"name": "Forge",
|
||||
"requires": [
|
||||
|
@ -14,7 +14,7 @@
|
|||
"version": "{FORGE_VERSION}",
|
||||
"libraries": [
|
||||
{
|
||||
"name": "io.github.zekerzhayard:ForgeWrapper:${version}",
|
||||
"name": "io.github.zekerzhayard:Forge-Wrapper:${version}",
|
||||
"MMC-hint": "local",
|
||||
"MMC-filename": "ForgeWrapper-${version}.jar"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue