Проверки на краш процесса

This commit is contained in:
Gravit 2018-10-13 15:30:05 +07:00
parent 441fdc92a4
commit e126623b6f
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -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
mainMethod.invoke((Object) args.toArray(EMPTY_ARRAY));
}
private static Process process = null;
@LauncherAPI
public static Process launch(
@ -301,6 +301,17 @@ public static Process launch(
socket.setReuseAddress(true);
socket.bind(new InetSocketAddress(SOCKET_HOST, SOCKET_PORT));
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())) {
params.write(output);
profile.write(output);
@ -375,7 +386,8 @@ public static Process launch(
builder.redirectOutput(Redirect.PIPE);
}
// Let's rock!
return builder.start();
process = builder.start();
return process;
}
@LauncherAPI