Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion proguard.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-dontoptimize
#-dontoptimize
-dontobfuscate
#-dontpreverify
-dontwarn javax.annotation.**
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/minecraftforge/installer/SimpleInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import net.minecraftforge.installer.actions.Actions;
import net.minecraftforge.installer.actions.ClientInstall;
import net.minecraftforge.installer.actions.FatInstallerAction;
import net.minecraftforge.installer.actions.ProgressCallback;
import net.minecraftforge.installer.actions.ServerInstall;
Expand Down Expand Up @@ -95,6 +96,12 @@ public static void main(String[] args) throws IOException, URISyntaxException {
OptionSpec<Void> fatIncludeInstallerLibs = parser.acceptsAll(Arrays.asList("fat-include-installer-libs"), "Include the installer libraries in the fat installer").availableIf(fatInstallerOption);
OptionSpec<Void> fatOffline = parser.acceptsAll(Arrays.asList("fat-offline", "gen-offline", "generate-offline", "gf"), "Generate an online fat installer");

OptionSpec<File> librariesFolderArg = parser.accepts("libraries", "Folder used to store downloaded libraries").availableIf(clientInstallOption, serverInstallOption).withOptionalArg().ofType(File.class);
OptionSpec<File> versionsFolderArg = parser.accepts("versions", "Folder used to store downloaded Minecraft versions").availableIf(clientInstallOption).withOptionalArg().ofType(File.class);
OptionSpec<Void> noLauncherProfileOption = parser.accepts("no-minecraft-launcher-profile", "Does not add a profile to the official Minecraft Launcher").availableIf(clientInstallOption);
OptionSpec<File> mergedVersionJsonFileArg = parser.accepts("write-merged-version-json", "Writes a merged copy of the Vanilla launcher version.json describing how to launch the game to the given path.").availableIf(clientInstallOption).withOptionalArg().ofType(File.class);
OptionSpec<Void> noDownloadLibrariesOption = parser.accepts("no-download-libraries", "Do not download any libraries that aren't necessary for the installer itself");

OptionSpec<Void> helpOption = parser.acceptsAll(Arrays.asList("h", "help"), "Help with this installer");
OptionSpec<Void> offlineOption = parser.accepts("offline", "Don't attempt any network calls");
OptionSpec<Void> debugOption = parser.accepts("debug", "Run in debug mode -- don't delete any files");
Expand Down Expand Up @@ -141,9 +148,16 @@ public static void main(String[] args) throws IOException, URISyntaxException {
action = Actions.SERVER;
target = optionSet.valueOf(serverInstallOption);
ServerInstall.serverStarterJar = optionSet.has(serverStarterOption);
ServerInstall.librariesDir = optionSet.valueOf(librariesFolderArg);
ServerInstall.skipLibrariesDownload = optionSet.has(noDownloadLibrariesOption);
} else if (optionSet.has(clientInstallOption)) {
action = Actions.CLIENT;
target = optionSet.valueOf(clientInstallOption);
ClientInstall.librariesDir = optionSet.valueOf(librariesFolderArg);
ClientInstall.versionsDir = optionSet.valueOf(versionsFolderArg);
ClientInstall.skipLauncherProfile = optionSet.has(noLauncherProfileOption);
ClientInstall.mergedVersionJsonFile = optionSet.valueOf(mergedVersionJsonFileArg);
ClientInstall.skipLibrariesDownload = optionSet.has(noDownloadLibrariesOption);
} else if (optionSet.has(fatInstallerOption) || optionSet.has(fatOffline)) {
action = Actions.FAT_INSTALLER;
target = optionSet.valueOf(fatInstallerOption);
Expand Down Expand Up @@ -179,6 +193,7 @@ public static void main(String[] args) throws IOException, URISyntaxException {
monitor.stage("You can delete this installer file now if you wish");
}
} catch (Throwable e) {
e.printStackTrace();
monitor.stage("A problem installing was detected, install cannot continue");
System.exit(1);
}
Expand Down Expand Up @@ -207,6 +222,7 @@ private static void launchGui(ProgressCallback monitor, File installer) {
InstallerPanel panel = new InstallerPanel(getMCDir(), profile, installer);
panel.run(monitor);
} catch (Throwable e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Something went wrong while installing.<br />Check log for more details:<br/>" + e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/net/minecraftforge/installer/actions/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import javax.swing.JOptionPane;
import net.minecraftforge.installer.DownloadUtils;
Expand Down Expand Up @@ -61,7 +63,13 @@ public String getSponsorMessage() {
return profile.getMirror() != null && profile.getMirror().isAdvertised() ? String.format(SimpleInstaller.headless ? "Data kindly mirrored by %2$s at %1$s" : "<html><a href=\'%s\'>Data kindly mirrored by %s</a></html>", profile.getMirror().getHomepage(), profile.getMirror().getName()) : null;
}

protected boolean downloadLibraries(File librariesDir, Predicate<String> optionals, List<File> additionalLibDirs) throws ActionCanceledException {
public enum LibraryCategory {
VANILLA,
NEOFORGE,
INSTALLER
}

protected boolean downloadLibraries(File librariesDir, Predicate<String> optionals, List<File> additionalLibDirs, Set<LibraryCategory> categories) throws ActionCanceledException {
monitor.start("Downloading libraries");
String userHome = System.getProperty("user.home");
if (userHome != null && !userHome.isEmpty()) {
Expand All @@ -73,8 +81,18 @@ protected boolean downloadLibraries(File librariesDir, Predicate<String> optiona
monitor.message(String.format("Found %d additional library directories", additionalLibDirs.size()));

List<Library> libraries = new ArrayList<>();
libraries.addAll(Arrays.asList(version.getLibraries()));
libraries.addAll(Arrays.asList(processors.getLibraries()));
if (categories.contains(LibraryCategory.VANILLA)) {
libraries.addAll(Arrays.asList(version.getLibraries()));
}
if (categories.contains(LibraryCategory.NEOFORGE)) {
libraries.addAll(Arrays.asList(profile.getLibraries()));
}
if (categories.contains(LibraryCategory.INSTALLER)) {
libraries.addAll(Arrays.asList(processors.getLibraries()));
}

Set<String> duplicates = new HashSet<>();
libraries.removeIf(library -> !duplicates.add(library.getDownloads() == null ? null : library.getDownloads().getArtifact().getPath()));

StringBuilder output = new StringBuilder();
monitor.getStepProgress().setMaxProgress(libraries.size());
Expand Down Expand Up @@ -102,10 +120,6 @@ protected int downloadedCount() {
return grabbed.size();
}

protected int getTaskCount() {
return profile.getLibraries().length + processors.getTaskCount();
}

protected void checkCancel() throws ActionCanceledException {
try {
Thread.sleep(1);
Expand Down
Loading