mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 21:07:36 +01:00
Possible fix for -nojline printing blank lines
This commit is contained in:
parent
480c1b9877
commit
6319a19073
@ -8,6 +8,7 @@ import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jline.ConsoleReader;
|
||||
import org.bukkit.craftbukkit.Main;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ThreadCommandReader extends Thread {
|
||||
@ -22,16 +23,15 @@ public class ThreadCommandReader extends Thread {
|
||||
// CraftBukkit start
|
||||
ConsoleReader bufferedreader = this.server.reader;
|
||||
String s = null;
|
||||
String jlineTerminalSetting = org.bukkit.craftbukkit.Main.jlineTerminalSetting;
|
||||
// CraftBukkit end
|
||||
|
||||
try {
|
||||
while (!this.server.isStopped && MinecraftServer.isRunning(this.server)) {
|
||||
// CraftBukkit start - JLine disabling compatibility
|
||||
if (jlineTerminalSetting != null && jlineTerminalSetting.equals("jline.UnsupportedTerminal")) {
|
||||
s = bufferedreader.readLine();
|
||||
} else {
|
||||
if (Main.useJline) {
|
||||
s = bufferedreader.readLine(">", null);
|
||||
} else {
|
||||
s = bufferedreader.readLine();
|
||||
}
|
||||
if (s != null) {
|
||||
// CraftBukkit end
|
||||
|
@ -12,7 +12,7 @@ import joptsimple.OptionSet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class Main {
|
||||
public static String jlineTerminalSetting;
|
||||
public static boolean useJline = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Todo: Installation script
|
||||
@ -88,11 +88,14 @@ public class Main {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
useJline = !"jline.UnsupportedTerminal".equals(System.getProperty("jline.terminal"));
|
||||
|
||||
if (options.has("nojline")) {
|
||||
System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
|
||||
System.setProperty("user.language", "en");
|
||||
useJline = false;
|
||||
}
|
||||
jlineTerminalSetting = System.getProperty("jline.terminal");
|
||||
|
||||
MinecraftServer.main(options);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
@ -5,6 +5,7 @@ import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jline.ConsoleReader;
|
||||
import org.bukkit.craftbukkit.Main;
|
||||
|
||||
public class TerminalConsoleHandler extends ConsoleHandler {
|
||||
private final ConsoleReader reader;
|
||||
@ -17,6 +18,7 @@ public class TerminalConsoleHandler extends ConsoleHandler {
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
try {
|
||||
if (Main.useJline) {
|
||||
reader.printString(ConsoleReader.RESET_LINE + "");
|
||||
reader.flushConsole();
|
||||
super.flush();
|
||||
@ -26,6 +28,9 @@ public class TerminalConsoleHandler extends ConsoleHandler {
|
||||
reader.getCursorBuffer().clearBuffer();
|
||||
}
|
||||
reader.flushConsole();
|
||||
} else {
|
||||
super.flush();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(TerminalConsoleHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user