forked from BLOCKFANTASY/LOOHP-Limbo
Skip encoding not-implemented item data components
This commit is contained in:
@@ -53,6 +53,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -72,23 +74,23 @@ public class Console implements CommandSender {
|
||||
protected final static String ERROR_RED = "\u001B[31;1m";
|
||||
protected final static String RESET_COLOR = "\u001B[0m";
|
||||
|
||||
private Terminal terminal;
|
||||
private LineReader tabReader;
|
||||
private ConsoleReader reader;
|
||||
private final Terminal terminal;
|
||||
private final LineReader tabReader;
|
||||
private final ConsoleReader reader;
|
||||
|
||||
private InputStream in;
|
||||
private final InputStream in;
|
||||
@SuppressWarnings("unused")
|
||||
private PrintStream out;
|
||||
private final PrintStream out;
|
||||
@SuppressWarnings("unused")
|
||||
private PrintStream err;
|
||||
protected PrintStream logs;
|
||||
private final PrintStream err;
|
||||
protected final PrintStream logs;
|
||||
|
||||
public Console(InputStream in, PrintStream out, PrintStream err) throws IOException {
|
||||
String fileName = new SimpleDateFormat("yyyy'-'MM'-'dd'_'HH'-'mm'-'ss'_'zzz'.log'").format(new Date());
|
||||
File dir = new File("logs");
|
||||
dir.mkdirs();
|
||||
File logs = new File(dir, fileName);
|
||||
this.logs = new PrintStream(logs);
|
||||
this.logs = new PrintStream(Files.newOutputStream(logs.toPath()), true, StandardCharsets.UTF_8.toString());
|
||||
|
||||
if (in != null) {
|
||||
System.setIn(in);
|
||||
@@ -256,7 +258,7 @@ public class Console implements CommandSender {
|
||||
while (true) {
|
||||
try {
|
||||
String command = tabReader.readLine(PROMPT).trim();
|
||||
if (command.length() > 0) {
|
||||
if (!command.isEmpty()) {
|
||||
String[] input = CustomStringUtils.splitStringToArgs(command);
|
||||
new Thread(() -> Limbo.getInstance().dispatchCommand(this, input)).start();
|
||||
}
|
||||
@@ -317,8 +319,8 @@ public class Console implements CommandSender {
|
||||
|
||||
public static class ConsoleOutputStream extends PrintStream {
|
||||
|
||||
private PrintStream logs;
|
||||
private Console console;
|
||||
private final PrintStream logs;
|
||||
private final Console console;
|
||||
|
||||
public ConsoleOutputStream(Console console, OutputStream out, PrintStream logs) {
|
||||
super(out);
|
||||
@@ -326,7 +328,6 @@ public class Console implements CommandSender {
|
||||
this.console = console;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public PrintStream printf(Locale l, String format, Object... args) {
|
||||
console.stashLine();
|
||||
@@ -338,7 +339,6 @@ public class Console implements CommandSender {
|
||||
return stream;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public PrintStream printf(String format, Object... args) {
|
||||
console.stashLine();
|
||||
@@ -453,8 +453,8 @@ public class Console implements CommandSender {
|
||||
|
||||
public static class ConsoleErrorStream extends PrintStream {
|
||||
|
||||
private PrintStream logs;
|
||||
private Console console;
|
||||
private final PrintStream logs;
|
||||
private final Console console;
|
||||
|
||||
public ConsoleErrorStream(Console console, OutputStream out, PrintStream logs) {
|
||||
super(out);
|
||||
|
||||
Reference in New Issue
Block a user