mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Проверки на краш процесса
This commit is contained in:
parent
441fdc92a4
commit
e126623b6f
1 changed files with 14 additions and 2 deletions
|
@ -285,7 +285,7 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
|
||||||
System.setProperty("minecraft.applet.TargetDirectory", params.clientDir.toString()); // For 1.5.2
|
System.setProperty("minecraft.applet.TargetDirectory", params.clientDir.toString()); // For 1.5.2
|
||||||
mainMethod.invoke((Object) args.toArray(EMPTY_ARRAY));
|
mainMethod.invoke((Object) args.toArray(EMPTY_ARRAY));
|
||||||
}
|
}
|
||||||
|
private static Process process = null;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public static Process launch(
|
public static Process launch(
|
||||||
|
|
||||||
|
@ -301,6 +301,17 @@ public static Process launch(
|
||||||
socket.setReuseAddress(true);
|
socket.setReuseAddress(true);
|
||||||
socket.bind(new InetSocketAddress(SOCKET_HOST, SOCKET_PORT));
|
socket.bind(new InetSocketAddress(SOCKET_HOST, SOCKET_PORT));
|
||||||
Socket client = socket.accept();
|
Socket client = socket.accept();
|
||||||
|
if(process == null)
|
||||||
|
{
|
||||||
|
LogHelper.error("Process is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!process.isAlive())
|
||||||
|
{
|
||||||
|
LogHelper.error("Process is not alive");
|
||||||
|
JOptionPane.showMessageDialog(null,"Client Process crashed","Launcher",JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try (HOutput output = new HOutput(client.getOutputStream())) {
|
try (HOutput output = new HOutput(client.getOutputStream())) {
|
||||||
params.write(output);
|
params.write(output);
|
||||||
profile.write(output);
|
profile.write(output);
|
||||||
|
@ -375,7 +386,8 @@ public static Process launch(
|
||||||
builder.redirectOutput(Redirect.PIPE);
|
builder.redirectOutput(Redirect.PIPE);
|
||||||
}
|
}
|
||||||
// Let's rock!
|
// Let's rock!
|
||||||
return builder.start();
|
process = builder.start();
|
||||||
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
|
Loading…
Reference in a new issue