mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Merge pull request #427 from AlexDicy/master
Handle Ctrl+C and SIGINT signal
This commit is contained in:
commit
01e39b5d98
@ -700,6 +700,9 @@ public final class MinecraftServer {
|
||||
if (terminalEnabled) {
|
||||
MinestomTerminal.start();
|
||||
}
|
||||
|
||||
// Stop the server on SIGINT
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(MinecraftServer::stopCleanly));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,9 @@ public class MinestomTerminal {
|
||||
command = reader.readLine(PROMPT);
|
||||
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
|
||||
} catch (UserInterruptException e) {
|
||||
// Ignore
|
||||
// Handle Ctrl + C
|
||||
System.exit(0);
|
||||
return;
|
||||
} catch (EndOfFileException e) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user