Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-20 05:20:07 +01:00
Possible fix for -nojline printing blank lines
Dieser Commit ist enthalten in:
Ursprung
480c1b9877
Commit
6319a19073
@ -8,6 +8,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import jline.ConsoleReader;
|
import jline.ConsoleReader;
|
||||||
|
import org.bukkit.craftbukkit.Main;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class ThreadCommandReader extends Thread {
|
public class ThreadCommandReader extends Thread {
|
||||||
@ -22,16 +23,15 @@ public class ThreadCommandReader extends Thread {
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
ConsoleReader bufferedreader = this.server.reader;
|
ConsoleReader bufferedreader = this.server.reader;
|
||||||
String s = null;
|
String s = null;
|
||||||
String jlineTerminalSetting = org.bukkit.craftbukkit.Main.jlineTerminalSetting;
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (!this.server.isStopped && MinecraftServer.isRunning(this.server)) {
|
while (!this.server.isStopped && MinecraftServer.isRunning(this.server)) {
|
||||||
// CraftBukkit start - JLine disabling compatibility
|
// CraftBukkit start - JLine disabling compatibility
|
||||||
if (jlineTerminalSetting != null && jlineTerminalSetting.equals("jline.UnsupportedTerminal")) {
|
if (Main.useJline) {
|
||||||
s = bufferedreader.readLine();
|
|
||||||
} else {
|
|
||||||
s = bufferedreader.readLine(">", null);
|
s = bufferedreader.readLine(">", null);
|
||||||
|
} else {
|
||||||
|
s = bufferedreader.readLine();
|
||||||
}
|
}
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
@ -12,7 +12,7 @@ import joptsimple.OptionSet;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static String jlineTerminalSetting;
|
public static boolean useJline = true;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Todo: Installation script
|
// Todo: Installation script
|
||||||
@ -88,11 +88,14 @@ public class Main {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
useJline = !"jline.UnsupportedTerminal".equals(System.getProperty("jline.terminal"));
|
||||||
|
|
||||||
if (options.has("nojline")) {
|
if (options.has("nojline")) {
|
||||||
System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
|
System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
|
||||||
System.setProperty("user.language", "en");
|
System.setProperty("user.language", "en");
|
||||||
|
useJline = false;
|
||||||
}
|
}
|
||||||
jlineTerminalSetting = System.getProperty("jline.terminal");
|
|
||||||
MinecraftServer.main(options);
|
MinecraftServer.main(options);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
@ -5,6 +5,7 @@ import java.util.logging.ConsoleHandler;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import jline.ConsoleReader;
|
import jline.ConsoleReader;
|
||||||
|
import org.bukkit.craftbukkit.Main;
|
||||||
|
|
||||||
public class TerminalConsoleHandler extends ConsoleHandler {
|
public class TerminalConsoleHandler extends ConsoleHandler {
|
||||||
private final ConsoleReader reader;
|
private final ConsoleReader reader;
|
||||||
@ -17,15 +18,19 @@ public class TerminalConsoleHandler extends ConsoleHandler {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void flush() {
|
public synchronized void flush() {
|
||||||
try {
|
try {
|
||||||
reader.printString(ConsoleReader.RESET_LINE + "");
|
if (Main.useJline) {
|
||||||
reader.flushConsole();
|
reader.printString(ConsoleReader.RESET_LINE + "");
|
||||||
super.flush();
|
reader.flushConsole();
|
||||||
try {
|
super.flush();
|
||||||
reader.drawLine();
|
try {
|
||||||
} catch (Throwable ex) {
|
reader.drawLine();
|
||||||
reader.getCursorBuffer().clearBuffer();
|
} catch (Throwable ex) {
|
||||||
|
reader.getCursorBuffer().clearBuffer();
|
||||||
|
}
|
||||||
|
reader.flushConsole();
|
||||||
|
} else {
|
||||||
|
super.flush();
|
||||||
}
|
}
|
||||||
reader.flushConsole();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(TerminalConsoleHandler.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(TerminalConsoleHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren