mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 22:47:49 +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) {
|
if (terminalEnabled) {
|
||||||
MinestomTerminal.start();
|
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 = reader.readLine(PROMPT);
|
||||||
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
|
COMMAND_MANAGER.execute(COMMAND_MANAGER.getConsoleSender(), command);
|
||||||
} catch (UserInterruptException e) {
|
} catch (UserInterruptException e) {
|
||||||
// Ignore
|
// Handle Ctrl + C
|
||||||
|
System.exit(0);
|
||||||
|
return;
|
||||||
} catch (EndOfFileException e) {
|
} catch (EndOfFileException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user