mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Stop the server on Ctrl+C and SIGINT signal
This commit is contained in:
parent
a8d90955c7
commit
c61a3dcd12
@ -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