Fix jline reader thread never being shutdown

This commit is contained in:
TheMode 2021-05-08 04:33:32 +02:00
parent b880788124
commit 073f5872f8

View File

@ -22,26 +22,31 @@ public class MinestomTerminal {
@ApiStatus.Internal
public static void start() {
try {
terminal = TerminalBuilder.terminal();
} catch (IOException e) {
e.printStackTrace();
}
LineReader reader = LineReaderBuilder.builder()
.terminal(terminal)
.build();
running = true;
while (running) {
String command;
final Thread thread = new Thread(null, () -> {
try {
command = reader.readLine(PROMPT);
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
} catch (UserInterruptException e) {
// Ignore
} catch (EndOfFileException e) {
return;
terminal = TerminalBuilder.terminal();
} catch (IOException e) {
e.printStackTrace();
}
}
LineReader reader = LineReaderBuilder.builder()
.terminal(terminal)
.build();
running = true;
while (running) {
String command;
try {
command = reader.readLine(PROMPT);
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
} catch (UserInterruptException e) {
// Ignore
} catch (EndOfFileException e) {
return;
}
}
}, "Jline");
thread.setDaemon(true);
thread.start();
}
@ApiStatus.Internal