-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from mircokroon/ui-fixes
UI fixes
- Loading branch information
Showing
18 changed files
with
182 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,50 @@ | ||
import config.Config; | ||
|
||
import util.PathUtils; | ||
|
||
import java.net.URISyntaxException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static util.ExceptionHandling.attemptQuiet; | ||
|
||
public class Launcher { | ||
public static void main(String[] args) { | ||
public static void main(String[] args) throws URISyntaxException { | ||
fixCwd(); | ||
|
||
Config.init(args); | ||
} | ||
|
||
private static void fixCwd() throws URISyntaxException { | ||
String cwd = System.getProperty("user.dir"); | ||
|
||
if (Files.isWritable(Paths.get(cwd))) { | ||
PathUtils.setWorkingDirectory(cwd); | ||
return; | ||
} | ||
|
||
// if we can't write to the working directory, try the jar file's location | ||
Path jarPath = Paths.get(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent(); | ||
if (Files.isWritable(jarPath)) { | ||
System.out.println("Can't write to working directory. Writing to " + jarPath); | ||
PathUtils.setWorkingDirectory(jarPath); | ||
|
||
return; | ||
} | ||
|
||
// if we can't write there, try the Minecraft installation dir | ||
Path mcPath = Paths.get(Config.getDefaultMinecraftPath(), "world-downloader"); | ||
attemptQuiet(() -> Files.createDirectories(mcPath)); | ||
if (Files.isWritable(mcPath)) { | ||
System.out.println("Can't write to working directory. Writing to " + mcPath); | ||
PathUtils.setWorkingDirectory(mcPath); | ||
|
||
return; | ||
} | ||
|
||
|
||
System.err.println("Unable to write data. Consider running with more permissions."); | ||
System.exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.