mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +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
|
@ApiStatus.Internal
|
||||||
public static void start() {
|
public static void start() {
|
||||||
try {
|
final Thread thread = new Thread(null, () -> {
|
||||||
terminal = TerminalBuilder.terminal();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
LineReader reader = LineReaderBuilder.builder()
|
|
||||||
.terminal(terminal)
|
|
||||||
.build();
|
|
||||||
running = true;
|
|
||||||
while (running) {
|
|
||||||
String command;
|
|
||||||
try {
|
try {
|
||||||
command = reader.readLine(PROMPT);
|
terminal = TerminalBuilder.terminal();
|
||||||
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
|
} catch (IOException e) {
|
||||||
} catch (UserInterruptException e) {
|
e.printStackTrace();
|
||||||
// Ignore
|
|
||||||
} catch (EndOfFileException e) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
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
|
@ApiStatus.Internal
|
||||||
|
Loading…
Reference in New Issue
Block a user