mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Fix jline reader thread never being shutdown
This commit is contained in:
parent
b880788124
commit
073f5872f8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user