mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Нормальное API для ClientLauncher.
This commit is contained in:
parent
331bb42822
commit
16fbab7bf5
1 changed files with 21 additions and 8 deletions
|
@ -311,9 +311,25 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
|
||||||
mainMethod.invokeWithArguments((Object)args.toArray(new String[0]));
|
mainMethod.invokeWithArguments((Object)args.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Process process = null;
|
private static Process process = null;
|
||||||
public static boolean clientStarted = false;
|
private static boolean clientStarted = false;
|
||||||
public static Thread writeParamsThread;
|
private static Thread writeParamsThread;
|
||||||
|
|
||||||
|
public static void setWriteParamsThread(Thread writeParamsThread) {
|
||||||
|
if (ClientLauncher.writeParamsThread != null && ClientLauncher.writeParamsThread.isAlive())
|
||||||
|
ClientLauncher.writeParamsThread.interrupt();
|
||||||
|
ClientLauncher.writeParamsThread = writeParamsThread;
|
||||||
|
ClientLauncher.writeParamsThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Process getProcess() {
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setClientStarted() {
|
||||||
|
clientStarted = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static PlayerProfile playerProfile;
|
public static PlayerProfile playerProfile;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -606,9 +622,7 @@ public ParamContainer read() throws Exception {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void write(ParamContainer p) throws Exception {
|
public void write(ParamContainer p) throws Exception {
|
||||||
if (writeParamsThread != null && writeParamsThread.isAlive())
|
setWriteParamsThread(CommonHelper.newThread("Client params writter", true, () ->
|
||||||
writeParamsThread.interrupt();
|
|
||||||
writeParamsThread = CommonHelper.newThread("Client params writter", true, () ->
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
try (ServerSocket socket = new ServerSocket()) {
|
try (ServerSocket socket = new ServerSocket()) {
|
||||||
|
@ -633,8 +647,7 @@ public void write(ParamContainer p) throws Exception {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
writeParamsThread.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue