From 0938b9b812aa8ee0a4025198d1f820c96478ea01 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 12 Apr 2021 17:06:38 +0200 Subject: [PATCH] Add ignoredlog for ignoring certain log output, each line one thing that should not be contained in the message case sensitive --- build.gradle | 16 ++++++++++++---- ignoredlog | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 ignoredlog diff --git a/build.gradle b/build.gradle index 7af6df1..9bb750d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,8 +17,8 @@ * along with this program. If not, see . */ + import org.apache.tools.ant.taskdefs.condition.Os -import org.codehaus.groovy.runtime.ProcessGroovyMethods plugins { // Adding the base plugin fixes the following gradle warnings in IntelliJ: @@ -138,6 +138,14 @@ private def shell(String command) { private def serverStart(String serverName) { def proc = shell("ssh -t ${hostname} \"./mc ${serverName}\"") + Set strings = new HashSet<>() + File file = new File("${projectDir}/ignoredlog"); + if (file.exists()) { + new BufferedReader(new InputStreamReader(new FileInputStream(file))).readLines().forEach({ s -> + strings.add(s) + }) + } + Thread outputThread = new Thread({ Reader reader = proc.getInputStream().newReader(); Writer writer = System.out.newWriter(); @@ -147,7 +155,7 @@ private def serverStart(String serverName) { if (s == null) { return } - if (s.contains("SteamWar? Unbekannter Befehl.")) { + if (strings.stream().anyMatch({check -> s.contains(check)})) { continue } writer.write(s + "\n") @@ -187,7 +195,7 @@ private def serverStart(String serverName) { awaitClose(proc, outputThread, inputThread) } awaitClose(proc, outputThread, inputThread) -} +}; private static def awaitClose(Process proc, Thread outputThread, Thread inputThread) { while (proc.alive) { @@ -201,7 +209,7 @@ private static def awaitClose(Process proc, Thread outputThread, Thread inputThr private def answer(String question) { while (System.in.available() > 0) System.in.read() println(question) - boolean valid = "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 diff --git a/ignoredlog b/ignoredlog new file mode 100644 index 0000000..b28379b --- /dev/null +++ b/ignoredlog @@ -0,0 +1,2 @@ +SteamWar? Unbekannter Befehl. +moved too quickly! \ No newline at end of file