oops, forgot to commit the ASU Update Cooldowns commands

This commit is contained in:
zontreck 2025-03-06 18:39:12 -07:00
parent 65ec65bfc9
commit 54e8d8a4d5
5 changed files with 159 additions and 9 deletions

View file

@ -148,6 +148,54 @@ namespace AriasServerUtils
.WithDescription("Update RTP Max block distance. Plus and/or minus this distance from player current position")
.HandleWith(Events.HandleUpdateASURTPMax)
.EndSubCommand()
.BeginSubCommand("cooldowns")
.WithDescription("Commands related to all the various cooldowns")
.BeginSubCommand("back")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(
parsers.Word("cooldown")
)
.WithDescription("Updates the cooldown time on /back (Default is 5s)")
.HandleWith(Events.HandleUpdateASUCDBack)
.EndSubCommand()
.BeginSubCommand("warp")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(
parsers.Word("cooldown")
)
.WithDescription("Updates the cooldown time on /warp (Default is 10s)")
.HandleWith(Events.HandleUpdateASUCDWarp)
.EndSubCommand()
.BeginSubCommand("home")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(
parsers.Word("cooldown")
)
.WithDescription("Updates the cooldown time on /home (Default is 5s)")
.HandleWith(Events.HandleUpdateASUCDHome)
.EndSubCommand()
.BeginSubCommand("spawn")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(
parsers.Word("cooldown")
)
.WithDescription("Updates the cooldown time on /spawn (Default is 5s)")
.HandleWith(Events.HandleUpdateASUCDSpawn)
.EndSubCommand()
.BeginSubCommand("rtp")
.RequiresPrivilege(Privilege.controlserver)
.WithArgs(
parsers.Word("cooldown")
)
.WithDescription("Updates the cooldown time on /rtp (Default is 30s)")
.HandleWith(Events.HandleUpdateASUCDRTP)
.EndSubCommand()
.BeginSubCommand("reset")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Resets all cooldowns to default values")
.HandleWith(Events.HandleUpdateASUCDReset)
.EndSubCommand()
.EndSubCommand()
.EndSubCommand()
.BeginSubCommand("help")
.RequiresPrivilege(Privilege.chat)

View file

@ -442,5 +442,103 @@ namespace AriasServerUtils
return TextCommandResult.Success();
}
internal static TextCommandResult HandleUpdateASUCDBack(TextCommandCallingArgs args)
{
if (args[0] is string CD)
{
ServerUtilities.config.Cooldowns[CooldownType.Back] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
else
{
ServerUtilities.config.Cooldowns[CooldownType.Back] = "5s";
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:config-value-reset"));
}
}
internal static TextCommandResult HandleUpdateASUCDWarp(TextCommandCallingArgs args)
{
if (args[0] is string CD)
{
ServerUtilities.config.Cooldowns[CooldownType.Warp] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
else
{
ServerUtilities.config.Cooldowns[CooldownType.Warp] = "10s";
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:config-value-reset"));
}
}
internal static TextCommandResult HandleUpdateASUCDHome(TextCommandCallingArgs args)
{
if (args[0] is string CD)
{
ServerUtilities.config.Cooldowns[CooldownType.Home] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
else
{
ServerUtilities.config.Cooldowns[CooldownType.Home] = "5s";
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:config-value-reset"));
}
}
internal static TextCommandResult HandleUpdateASUCDSpawn(TextCommandCallingArgs args)
{
if (args[0] is string CD)
{
ServerUtilities.config.Cooldowns[CooldownType.Spawn] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
else
{
ServerUtilities.config.Cooldowns[CooldownType.Spawn] = "5s";
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:config-value-reset"));
}
}
internal static TextCommandResult HandleUpdateASUCDRTP(TextCommandCallingArgs args)
{
if (args[0] is string CD)
{
ServerUtilities.config.Cooldowns[CooldownType.RTP] = CD;
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
else
{
ServerUtilities.config.Cooldowns[CooldownType.RTP] = "30s";
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:config-value-reset"));
}
}
internal static TextCommandResult HandleUpdateASUCDReset(TextCommandCallingArgs args)
{
ServerUtilities.config.Cooldowns = ServerUtilities.config.GetDefaultCooldowns();
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:config-value-reset"));
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;
using Vintagestory.API.Server;
namespace AriasServerUtils
@ -13,6 +14,15 @@ namespace AriasServerUtils
[Serializable]
public class ASUModConfig
{
private readonly static Dictionary<CooldownType, string> m_defaultCD = new Dictionary<CooldownType, string>{
{ CooldownType.Home, "5s" },
{ CooldownType.Warp, "10s" },
{ CooldownType.Spawn, "5s" },
{ CooldownType.RTP, "30s" },
{ CooldownType.Back, "5s" }
};
public int MaxHomes { get; set; } = 20;
public bool AdminsBypassMaxHomes { get; set; } = true;
public bool onlyAdminsCreateWarps { get; set; } = true;
@ -30,14 +40,7 @@ namespace AriasServerUtils
public Dictionary<CooldownType, string> GetDefaultCooldowns()
{
return new Dictionary<CooldownType, string>{
{ CooldownType.Home, "5s" },
{ CooldownType.Warp, "10s" },
{ CooldownType.Spawn, "5s" },
{ CooldownType.RTP, "30s" },
{ CooldownType.Back, "5s" }
};
return m_defaultCD;
}
public void SanityCheckCooldowns()

View file

@ -21,6 +21,7 @@
"help": "All Aria's Server Utilities Commands: \n\nMax Homes: {0}; \nAdmins can bypass max homes: {1}\nMax back positions: {2}\n\n{3}",
"updatedconfig": "[ASU] server config updated",
"config-value-reset": "[ASU] server config value reset to default",
"warp-tp": "Teleported to warp [{0}]",
"warp-set": "Warp [{0}] created!",

View file

@ -3,7 +3,7 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
"description": "A collection of server utilities\n\nBuild Date: 03-06-2025 @ 6:16 PM MST",
"description": "A collection of server utilities\n\nBuild Date: 03-06-2025 @ 6:37 PM MST",
"version": "1.0.4",
"dependencies": {
"game": ""