From 534673cdc57cc799de9f6dfc06c3f70213d80e32 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Apr 2021 21:38:16 +0200 Subject: [PATCH] Fix build.gradle with interactive serverStart --- build.gradle | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index e789d1d..6a94ff7 100644 --- a/build.gradle +++ b/build.gradle @@ -130,7 +130,7 @@ def shell(String command) { } def serverStart() { - def proc = shell("ssh ${hostname} \"./mc Dev1.15\"") + def proc = shell("ssh -t ${hostname} \"./mc Dev1.15\"") Thread outputThread = proc.consumeProcessOutputStream(System.out) outputThread.setName("OutputThread") @@ -138,13 +138,16 @@ def serverStart() { Thread inputThread = new Thread(new Runnable() { @Override void run() { - // Reader reader = System.in.newReader() + Reader reader = System.in.newReader() Writer writer = proc.getOutputStream().newWriter() - while (true) { - //String s = reader.readLine() - Thread.sleep(10000) - writer.write("stop\n") - writer.flush() + try { + while (true) { + String s = reader.readLine() + writer.write(s + "\n") + writer.flush() + } + } catch (InterruptedIOException e) { + } } }) @@ -162,5 +165,7 @@ def serverStart() { def answer(String question) { while (System.in.available() > 0) System.in.read() println(question) - return "Yy".contains(((char)System.in.read()).toString()) + boolean valid = "Yy".contains(((char)System.in.read()).toString()) + while (System.in.available() > 0) System.in.read() + return valid } \ No newline at end of file