Skip to content

Commit

Permalink
Added support for the user gradle cache being in a non-standard locat…
Browse files Browse the repository at this point in the history
…ion. Closes #17.

UNTESTED! Should work in theory, but let me know if I screwed up.
  • Loading branch information
Parker8283 committed Dec 8, 2015
1 parent f2f8549 commit 7f0f264
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/github/parker8283/bon2/BON2.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.github.parker8283.bon2.cli.CLIErrorHandler;
import com.github.parker8283.bon2.cli.CLIProgressListener;
import com.github.parker8283.bon2.data.BONFiles;
import com.github.parker8283.bon2.data.IErrorHandler;
import com.github.parker8283.bon2.exception.InvalidMappingsVersionException;
import com.github.parker8283.bon2.util.BONUtils;
Expand All @@ -34,7 +35,7 @@ private static void parseArgs(String[] args) throws Exception {
parser.accepts("inputJar", "The jar file to deobfuscate").withRequiredArg().required();
parser.accepts("outputJar", "The location and name of the output jar. Defaults to same dir and appends \"-deobf\"").withRequiredArg();
parser.accepts("mappingsVer", "The version of the mappings to use. Must exist in Gradle cache. Format is \"mcVer-forgeVer-mappingVer\". For use with FG2, use \"1.8(.8)-mappingVer\". This is a temporary solution until BON 2.3.").withRequiredArg().required();
parser.accepts("debug", "Enables extra debug logging. Helpful to figure out what the hell is going on.");
parser.accepts("userGradle", "If your user gradle folder is not in the default spot, specify its location here.").withRequiredArg();

try {
OptionSet options = parser.parse(args);
Expand All @@ -51,7 +52,9 @@ private static void parseArgs(String[] args) throws Exception {
String inputJar = (String)options.valueOf("inputJar");
String outputJar = options.has("outputJar") ? (String)options.valueOf("outputJar") : inputJar.replace(".jar", "-deobf.jar");
String mappingsVer = (String)options.valueOf("mappingsVer");
boolean debug = options.has("debug");
if(options.has("userGradle")) {
BONFiles.setUserHome(new File((String)options.valueOf("userGradle")));
}
if(!new File(inputJar).exists()) {
System.err.println("The provided inputJar does not exist");
new FileNotFoundException(inputJar).printStackTrace();
Expand All @@ -65,10 +68,10 @@ private static void parseArgs(String[] args) throws Exception {
IErrorHandler errorHandler = new CLIErrorHandler();

log(VERSION);
log("Input JAR: " + inputJar);
log("Output JAR: " + outputJar);
log("Mappings: " + mappingsVer);
log("Debug: " + debug);
log("Input JAR: " + inputJar);
log("Output JAR: " + outputJar);
log("Mappings: " + mappingsVer);
log("Gradle User Dir: " + BONFiles.USER_GRADLE_FOLDER);

try {
BON2Impl.remap(new File(inputJar), new File(outputJar), mappingsVer, errorHandler, new CLIProgressListener());
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/github/parker8283/bon2/data/BONFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.File;

public class BONFiles {
public static final File USER_GRADLE_FOLDER = new File(System.getProperty("user.home") + File.separator + ".gradle");
public static File USER_GRADLE_FOLDER = new File(System.getProperty("user.home") + File.separator + ".gradle");
public static final File GRADLE_CACHES_FOLDER = new File(USER_GRADLE_FOLDER, "caches");
public static final File CACHES_MINECRAFT_FOLDER = new File(GRADLE_CACHES_FOLDER, "minecraft");
public static final File MINECRAFT_NET_FOLDER = new File(CACHES_MINECRAFT_FOLDER, "net");
Expand All @@ -12,4 +12,8 @@ public class BONFiles {
public static final File MINECRAFT_DE_FOLDER = new File(CACHES_MINECRAFT_FOLDER, "de");
public static final File DE_OCEANLABS_FOLDER = new File(MINECRAFT_DE_FOLDER, "oceanlabs");
public static final File OCEANLABS_MCP_FOLDER = new File(DE_OCEANLABS_FOLDER, "mcp");

public static void setUserHome(File userGradle) {
USER_GRADLE_FOLDER = userGradle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RefreshListener(Component parent, JComboBox comboBox) {
@Override
public void mouseClicked(MouseEvent e) {
if(!BONFiles.USER_GRADLE_FOLDER.exists()) {
JOptionPane.showMessageDialog(parent, "No user .gradle folder found. You must run ForgeGradle at least once in order to use this tool.", BON2Gui.ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(parent, "No user .gradle folder found. You must run ForgeGradle at least once in order to use this tool.\n\nNOTE: If your GRADLE_USER_HOME is NOT in the default place, you can specify its location from the CLI version of BON2. Run BON2 with \"--help\" for info on doing that. This will be fixed for the GUI version in BON 2.3.", BON2Gui.ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
} else if(!BONFiles.USER_GRADLE_FOLDER.isDirectory()) {
JOptionPane.showMessageDialog(parent, "The user .gradle isn't a folder. Delete it and try again.", BON2Gui.ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
}
Expand Down

0 comments on commit 7f0f264

Please sign in to comment.