Use TerminalConsoleAppender for console improvements

Rewrite console improvements (console colors, tab completion,
persistent input line, ...) using JLine 3.x and TerminalConsoleAppender.

Also uses the new ANSIComponentSerializer to serialize components when
logging them via the ComponentLogger, or when sending messages to the
console, for hex color support.

New features:
  - Support console colors for Vanilla commands
  - Add console colors for warnings and errors
  - Server can now be turned off safely using CTRL + C. JLine catches
    the signal and the implementation shuts down the server cleanly.
  - Support console colors and persistent input line when running in
    IntelliJ IDEA

Other changes:
  - Server starts 1-2 seconds faster thanks to optimizations in Log4j
    configuration

Co-Authored-By: Emilia Kond <emilia@rymiel.space>
This commit is contained in:
Minecrell
2017-06-09 19:03:43 +02:00
parent 66779f5c86
commit 36723cdd60
19 changed files with 343 additions and 133 deletions

View File

@@ -16,7 +16,7 @@ public class ServerShutdownThread extends Thread {
this.server.close();
} finally {
try {
this.server.reader.getTerminal().restore();
net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
} catch (Exception e) {
}
}

View File

@@ -4,14 +4,12 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import jline.console.ConsoleReader;
import jline.console.completer.CompletionHandler;
/**
* SPIGOT-6705: Make sure we print the display line again on tab completion, so that the user does not get stuck on it
* e.g. The user needs to press y / n to continue
*/
public class TerminalCompletionHandler implements CompletionHandler {
public class TerminalCompletionHandler /* implements CompletionHandler */ { /* Paper - comment out whole class
private final TerminalConsoleWriterThread writerThread;
private final CompletionHandler delegate;
@@ -50,4 +48,5 @@ public class TerminalCompletionHandler implements CompletionHandler {
return result;
}
*/ // Paper end - comment out whole class
}

View File

@@ -7,13 +7,9 @@ import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import jline.console.ConsoleReader;
import jline.console.completer.CandidateListCompletionHandler;
import org.bukkit.craftbukkit.Main;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Erase;
public class TerminalConsoleWriterThread extends Thread {
public class TerminalConsoleWriterThread /*extends Thread*/ {/* // Paper - Comment out entire class
private final ResourceBundle bundle = ResourceBundle.getBundle(CandidateListCompletionHandler.class.getName(), Locale.getDefault());
private final ConsoleReader reader;
private final OutputStream output;
@@ -70,4 +66,5 @@ public class TerminalConsoleWriterThread extends Thread {
void setCompletion(int completion) {
this.completion = completion;
}
*/ // Paper - Comment out entire class
}