Add a command to list cooldown settings and all active command cooldowns for the current player

This commit is contained in:
zontreck 2025-03-07 12:05:04 -07:00
parent c5c605d057
commit 29cf4e21b7
3 changed files with 28 additions and 6 deletions

View file

@ -130,7 +130,7 @@ namespace AriasServerUtils
.WithArgs(
parsers.Bool("bypass")
)
.WithDescription("This flag controls whether admins can or can not bypass the cooldown system")
.WithDescription("This flag controls whether admins can or can not bypass the cooldown system (Default: true)")
.HandleWith(Events.HandleUpdateASUBypassCD)
.EndSubCommand()
.BeginSubCommand("adminsBypassRTPMaxDist")
@ -138,7 +138,7 @@ namespace AriasServerUtils
.WithArgs(
parsers.Bool("bypass")
)
.WithDescription("This flag would allow admins to go further than the max server RTP distance when manually specifying a distance to RTP")
.WithDescription("This flag would allow admins to go further than the max server RTP distance when manually specifying a distance to RTP (Default: false)")
.HandleWith(Events.HandleUpdateASUBypassRTPMaxDist)
.EndSubCommand()
.BeginSubCommand("maxback")
@ -162,7 +162,7 @@ namespace AriasServerUtils
.WithArgs(
parsers.Int("maxDistance")
)
.WithDescription("Update RTP Max block distance. Plus and/or minus this distance from player current position")
.WithDescription("Update RTP Max block distance. Plus and/or minus this distance from player current position (Default is 50000)")
.HandleWith(Events.HandleUpdateASURTPMax)
.EndSubCommand()
.BeginSubCommand("cooldowns")
@ -228,6 +228,8 @@ namespace AriasServerUtils
api.ChatCommands.Create("back").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Returns you to the last location you were at").HandleWith(Events.HandleBack);
api.ChatCommands.Create("rtp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithArgs(parsers.OptionalInt("maxDist", defaultValue: -1)).WithDescription("Seeks a position possibly thousands of blocks away to teleport to.").HandleWith(Events.HandleRTP);
api.ChatCommands.Create("listcooldowns").RequiresPrivilege(Privilege.chat).WithDescription("Lists the cooldown settings on the server, as well as your own active cooldowns if applicable.").HandleWith(Events.HandleListCooldowns);
}
private void OnCheckPlayerCooldowns()

View file

@ -14,7 +14,7 @@ namespace AriasServerUtils
{
internal static TextCommandResult HandleASU(TextCommandCallingArgs args)
{
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:help", ServerUtilities.config.MaxHomes, ServerUtilities.config.AdminsBypassMaxHomes, ServerUtilities.config.MaxBackCache, string.Join(", ", new string[] { "setspawn", "spawn", "delspawn", "sethome", "home", "delhome", "homes", "restoreinv", "asu", "warp", "setwarp", "delwarp", "warps", "back", "rtp" })));
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:help", ServerUtilities.config.MaxHomes, ServerUtilities.config.AdminsBypassMaxHomes, ServerUtilities.config.MaxBackCache, string.Join(", ", new string[] { "setspawn", "spawn", "delspawn", "sethome", "home", "delhome", "homes", "restoreinv", "asu", "warp", "setwarp", "delwarp", "warps", "back", "rtp", "listcooldowns" })));
}
internal static TextCommandResult HandleBack(TextCommandCallingArgs args)
@ -579,5 +579,25 @@ namespace AriasServerUtils
}
else return TextCommandResult.Success();
}
internal static TextCommandResult HandleListCooldowns(TextCommandCallingArgs args)
{
string sReturn = "SERVER COOLDOWN SETTINGS\n";
foreach (var cd in ServerUtilities.config.Cooldowns)
{
sReturn += $"{cd.Key}: {cd.Value}\n";
}
if (args.Caller.Player is IServerPlayer isp)
{
sReturn += "\nYour active cooldowns:";
foreach (var cd in ServerUtilities.GetPlayerData(isp).ActiveCooldowns)
{
long remain = cd.Value - TimeUtil.GetUnixEpochTimestamp();
string sCDVal = TimeUtil.EncodeTimeNotation(remain);
sReturn += $"{cd.Key}: {sCDVal}\n";
}
}
return TextCommandResult.Success(sReturn);
}
}
}

View file

@ -3,8 +3,8 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
"description": "A collection of server utilities\n\nBuild Date: 03-07-2025 @ 11:53 AM MST",
"version": "1.0.6-dev.3",
"description": "A collection of server utilities\n\nBuild Date: 03-07-2025 @ 12:04 PM MST",
"version": "1.0.6-dev.4",
"dependencies": {
"game": ""
}