Finish setting up the ASU command for managing the server settings, and listing all available asu commands

This commit is contained in:
zontreck 2025-01-18 15:12:22 -07:00
parent bd28f36e00
commit 70664e91c4
4 changed files with 51 additions and 3 deletions

View file

@ -85,6 +85,24 @@ namespace AriasServerUtils
api.ChatCommands.Create("home").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Teleports you to home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleGoHome);
api.ChatCommands.Create("delhome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Deletes a home entry").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleDelHome);
api.ChatCommands.Create("homes").RequiresPlayer().WithDescription("Lists your homes").RequiresPrivilege(Privilege.controlserver).HandleWith(Events.HandleListHomes);
api.ChatCommands.Create("asu")
.RequiresPrivilege(Privilege.chat)
.BeginSubCommand("update")
.RequiresPlayer()
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(
parsers.Int("maxHomes"),
parsers.Bool("adminsBypass"))
.HandleWith(Events.HandleUpdateASU)
.WithDescription("Updates the ASU mod configuration")
.EndSubCommand()
.BeginSubCommand("help")
.RequiresPlayer()
.RequiresPrivilege(Privilege.chat)
.HandleWith(Events.HandleASU)
.WithDescription("Lists all Aria's Server Utils commands")
.EndSubCommand();
}
private void OnPlayerDC(IServerPlayer byPlayer)

View file

@ -10,6 +10,11 @@ namespace AriasServerUtils
{
public class Events
{
internal static TextCommandResult HandleASU(TextCommandCallingArgs args)
{
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:help", ServerUtilities.config.MaxHomes, ServerUtilities.config.AdminsBypassMaxHomes, string.Join(", ", new string[] { "setspawn", "spawn", "delspawn", "sethome", "home", "delhome", "homes", "restoreinv", "asu" })));
}
internal static TextCommandResult HandleClearSpawn(TextCommandCallingArgs args)
{
ServerUtilities.config.Spawn = null;
@ -179,5 +184,26 @@ namespace AriasServerUtils
return TextCommandResult.Success();
}
internal static TextCommandResult HandleUpdateASU(TextCommandCallingArgs args)
{
if (args[0] is int maxHomes)
{
ServerUtilities.config.MaxHomes = maxHomes;
if (args[1] is bool bypass)
{
ServerUtilities.config.AdminsBypassMaxHomes = bypass;
}
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
return TextCommandResult.Success();
}
}
}

View file

@ -16,5 +16,9 @@
"home-max": "You have reached your max number of homes",
"home-set": "Home saved",
"home-del": "Home deleted",
"home-list": "You have [{0}] home(s)\n\n{1}"
"home-list": "You have [{0}] home(s)\n\n{1}",
"help": "All Aria's Server Utilities Commands: \n\nMax Homes: {0}; Admins can bypass max homes: {1}\n{2}",
"updatedconfig": "[ASU] server config updated"
}

View file

@ -3,8 +3,8 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
"description": "A collection of server utilities\n\nBuild Date: 01-18-2025 @ 02:43 PM",
"version": "1.0.0-dev.9",
"description": "A collection of server utilities\n\nBuild Date: 01-18-2025 @ 02:46 PM",
"version": "1.0.0-dev.10",
"dependencies": {
"game": ""
}