Skip to content

Commit 4732bee

Browse files
committed
修复一些无法运行的问题
1 parent 882f6f0 commit 4732bee

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/main/java/com/github/balloonupdate/mcpatch/client/Main.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,16 @@ static Path getUpdateDirectory(Path workDir, AppConfig config) throws McpatchBus
300300
*/
301301
static Path searchDotMinecraft(Path basedir) {
302302
try {
303-
Path d = basedir;
303+
File d = basedir.toFile();
304304

305305
for (int i = 0; i < 7; i++) {
306-
if (d.toFile().getName().contains(".minecraft")) {
307-
return d;
306+
for (File f : d.listFiles()) {
307+
if (f.getName().equals(".minecraft")) {
308+
return d.toPath();
309+
}
308310
}
309311

310-
d = d.getParent();
312+
d = d.getParentFile();
311313
}
312314
} catch (NullPointerException e) {
313315
return null;
@@ -359,7 +361,7 @@ static Map<String, Object> readConfig(Path external) throws McpatchBusinessExcep
359361
// }
360362
// }
361363
} catch (ParserException | IOException e) {
362-
throw new McpatchBusinessException(e.getMessage());
364+
throw new McpatchBusinessException(e);
363365
}
364366
}
365367

src/main/java/com/github/balloonupdate/mcpatch/client/utils/Env.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public static Path getJarPath()
5959
try {
6060
String url = URLDecoder.decode(Env.class.getProtectionDomain().getCodeSource().getLocation().getFile(), "UTF-8").replace("\\", "/");
6161

62-
if (url.startsWith("/"))
62+
boolean windows = System.getProperty("os.name").toLowerCase().contains("win");
63+
64+
if (windows && url.startsWith("/"))
6365
url = url.substring(1);
6466

6567
if (url.endsWith(".class") && url.contains("!")) {

0 commit comments

Comments
 (0)