From 16fbab7bf59784a54b36f2e0db89eba1655c12e6 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Mon, 7 Oct 2019 17:57:38 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9D=D0=BE=D1=80=D0=BC=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=D0=B5=20API=20=D0=B4=D0=BB=D1=8F=20ClientLau?= =?UTF-8?q?ncher.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/client/ClientLauncher.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index 4c37ff3f..73c146d0 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -311,9 +311,25 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl mainMethod.invokeWithArguments((Object)args.toArray(new String[0])); } - public static Process process = null; - public static boolean clientStarted = false; - public static Thread writeParamsThread; + private static Process process = null; + private static boolean clientStarted = false; + 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; @LauncherAPI @@ -606,9 +622,7 @@ public ParamContainer read() throws Exception { } @Override public void write(ParamContainer p) throws Exception { - if (writeParamsThread != null && writeParamsThread.isAlive()) - writeParamsThread.interrupt(); - writeParamsThread = CommonHelper.newThread("Client params writter", true, () -> + setWriteParamsThread(CommonHelper.newThread("Client params writter", true, () -> { try { try (ServerSocket socket = new ServerSocket()) { @@ -633,8 +647,7 @@ public void write(ParamContainer p) throws Exception { } catch (IOException e) { LogHelper.error(e); } - }); - writeParamsThread.start(); + })); } };