SteamWar/BauSystem
Archiviert
13
0

Add ignoredlog for ignoring certain log output, each line one thing that should not be contained in the message case sensitive

Dieser Commit ist enthalten in:
yoyosource 2021-04-12 17:06:38 +02:00
Ursprung 1d57f8ff4d
Commit 0938b9b812
2 geänderte Dateien mit 14 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -17,8 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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<String> 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
}

2
ignoredlog Normale Datei
Datei anzeigen

@ -0,0 +1,2 @@
SteamWar? Unbekannter Befehl.
moved too quickly!