mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-25 00:07:36 +01:00
JLine 2 allows for better color matching in the console and support for colors in console on Windows. Hopefully provides better performance as well.
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package org.bukkit.craftbukkit.util;
|
|
|
|
import java.io.IOException;
|
|
import java.util.logging.ConsoleHandler;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import jline.console.ConsoleReader;
|
|
import org.bukkit.craftbukkit.Main;
|
|
|
|
public class TerminalConsoleHandler extends ConsoleHandler {
|
|
private final ConsoleReader reader;
|
|
|
|
public TerminalConsoleHandler(ConsoleReader reader) {
|
|
super();
|
|
this.reader = reader;
|
|
}
|
|
|
|
@Override
|
|
public synchronized void flush() {
|
|
try {
|
|
if (Main.useJline) {
|
|
reader.print(ConsoleReader.RESET_LINE + "");
|
|
reader.flush();
|
|
super.flush();
|
|
try {
|
|
reader.drawLine();
|
|
} catch (Throwable ex) {
|
|
reader.getCursorBuffer().clear();
|
|
}
|
|
reader.flush();
|
|
} else {
|
|
super.flush();
|
|
}
|
|
} catch (IOException ex) {
|
|
Logger.getLogger(TerminalConsoleHandler.class.getName()).log(Level.SEVERE, null, ex);
|
|
}
|
|
}
|
|
}
|