feat: Adds console commands (#1714)

### Summary
* Adds console command support.
* Adds `save`, `restart`, and `shutdown` commands.
This commit is contained in:
Kamron Batman 2024-03-30 09:40:43 -07:00 • committed by GitHub
parent 855f8c67ae
commit e638fb7893
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 233 additions and 13 deletions

View file

@ -0,0 +1,27 @@
using Server.Saves;
namespace Server.Misc;
public static class ConsoleCommands
{
public static void Configure()
{
ConsoleInputHandler.RegisterCommand(
["save", "s"],
"Saves the world",
_ => Core.LoopContext.Post(AutoSave.Save)
);
ConsoleInputHandler.RegisterCommand(
["shutdown", "sh"],
"Shuts down the server.",
_ => Core.Kill()
);
ConsoleInputHandler.RegisterCommand(
["restart", "r"],
"Restarts the server.",
_ => Core.Kill(true)
);
}
}