Skip to content

Commit

Permalink
Changed default Minecraft path on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
mircokroon committed Apr 4, 2020
1 parent 478d4e7 commit 5149994
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main/java/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.commons.lang3.SystemUtils;

import java.nio.file.Paths;

Expand Down Expand Up @@ -55,7 +56,7 @@ private static Namespace getArguments(String[] args) {
.type(Long.class)
.help("Level seed for output file, as a long.");
parser.addArgument("-m", "--minecraft")
.setDefault(Paths.get("%appdata%", ".minecraft").toString())
.setDefault(getDefaultPath())
.help("Path to your Minecraft installation, used to authenticate with Mojang servers.");
parser.addArgument("-r", "--render-distance").dest("render-distance")
.setDefault(75)
Expand All @@ -79,4 +80,18 @@ private static Namespace getArguments(String[] args) {
}
return ns;
}

/**
* Get the platform-specific default path for the Minecraft installation directory.
* @return the path as a string
*/
private static String getDefaultPath() {
if (SystemUtils.IS_OS_WINDOWS) {
return Paths.get("%appdata%", ".minecraft").toString();
} else if (SystemUtils.IS_OS_LINUX) {
return Paths.get("~", ".minecraft").toString();
} else {
return ".minecraft";
}
}
}

0 comments on commit 5149994

Please sign in to comment.