SPIGOT-6063: ConsoleSender sending extra lines in Java 13+

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2020-09-12 09:05:20 +10:00
parent c6d968eda2
commit 3c76d377fa
3 changed files with 22 additions and 50 deletions

View File

@@ -1,31 +0,0 @@
package org.bukkit.craftbukkit;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
public class LoggerOutputStream extends ByteArrayOutputStream {
private final String separator = System.getProperty("line.separator");
private final Logger logger;
private final Level level;
public LoggerOutputStream(Logger logger, Level level) {
super();
this.logger = logger;
this.level = level;
}
@Override
public void flush() throws IOException {
synchronized (this) {
super.flush();
String record = this.toString();
super.reset();
if ((record.length() > 0) && (!record.equals(separator))) {
logger.log(level, record);
}
}
}
}