Skip to content

Commit 9d397e2

Browse files
committed
Fix installer and add a "--dist" option.
1 parent b54cb63 commit 9d397e2

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

loader/src/main/java/com/fox2code/foxloader/installer/InstallerGUI.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ public void installMineCraft() {
264264
}
265265

266266
public void extractMMCInstance() {
267+
String fileName = Main.currentInstallerFile.getName();
268+
if (fileName.endsWith("-installer.jar")) {
269+
fileName = fileName.replace("-installer.jar", ".jar");
270+
}
271+
this.extractMMCInstance(fileName);
272+
}
273+
274+
public void extractMMCInstance(String baseFileName) {
267275
if (this.checkInstaller(true)) {
268276
return;
269277
}
@@ -272,9 +280,8 @@ public void extractMMCInstance() {
272280
privateDevBuildSlimJarInput = DependencyHelper.getLocalSlimReIndevJarFile();
273281
}
274282

275-
String fileName = Main.currentInstallerFile.getName();
276283
File instanceDest = new File(Main.currentInstallerFile.getParentFile(),
277-
fileName.substring(0, fileName.length() - 4) + "-mmc.zip");
284+
baseFileName.substring(0, baseFileName.length() - 4) + "-mmc.zip");
278285
try (ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(instanceDest.toPath()))) {
279286
zipOutputStream.putNextEntry(new ZipEntry("libraries/foxloader-" + BuildConfig.FOXLOADER_VERSION + ".jar"));
280287
copyCloseIn(Files.newInputStream(Main.currentInstallerFile.toPath()), zipOutputStream);
@@ -287,7 +294,7 @@ public void extractMMCInstance() {
287294
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
288295
for (String entry : new String[]{"patches/com.fox2code.foxloader.json",
289296
"patches/net.minecraft.json", "patches/net.minecraftforge.json",
290-
"instance.cfg", "mmc-pack.json"}) {
297+
"patches/org.lwjgl.json", "instance.cfg", "mmc-pack.json"}) {
291298
zipOutputStream.putNextEntry(new ZipEntry(entry));
292299
byteArrayOutputStream.reset();
293300
IOUtils.copyAndClose(InstallerGUI.class.getResourceAsStream(

loader/src/main/java/com/fox2code/foxloader/installer/Main.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.awt.*;
88
import java.io.File;
99
import java.io.IOException;
10+
import java.nio.file.Files;
1011
import java.util.Arrays;
1112
import java.util.Locale;
1213

@@ -19,6 +20,7 @@ public static void main(String[] args) throws Throwable {
1920
}
2021
boolean platform = false;
2122
boolean update = false;
23+
boolean dist = false;
2224
if (args.length >= 1) {
2325
boolean server = false;
2426
boolean nogui = false;
@@ -41,11 +43,30 @@ public static void main(String[] args) throws Throwable {
4143
case "--server":
4244
server = true;
4345
break;
46+
case "--dist":
47+
dist = true;
48+
break;
4449
default:
4550
System.out.println("Unknown argument: " + args[0]);
4651
return;
4752
}
4853

54+
if (dist) {
55+
String installerName = currentInstallerFile.getName();
56+
InstallerGUI installerGUI = new InstallerGUI(InstallerPlatform.DEFAULT, LauncherType.MMC_LIKE);
57+
if (installerName.startsWith("loader-") && !installerName.endsWith("-installer.jar")) {
58+
File newName = new File("fox" + installerName.substring(
59+
0, installerName.length() - 3) + "-installer.jar");
60+
if (!newName.exists()) {
61+
Files.copy(currentInstallerFile.toPath(), newName.toPath());
62+
}
63+
installerGUI.extractMMCInstance("fox" + installerName);
64+
} else {
65+
installerGUI.extractMMCInstance();
66+
}
67+
return;
68+
}
69+
4970
if (server) {
5071
if (nogui) {
5172
ServerMain.main(new String[]{"nogui"});

0 commit comments

Comments
 (0)