Add update commands for cost configs

Part of #6
This commit is contained in:
zontreck 2025-06-07 13:47:46 -07:00
parent 8d875653e0
commit c269066a26
5 changed files with 213 additions and 7 deletions

View file

@ -560,7 +560,15 @@ namespace AriasServerUtils
{
if (isp.HasPrivilege(Privilege.controlserver) || !ServerUtilities.config.onlyAdminsCreateWarps)
{
int cost = ServerUtilities.config.cmdCosts.costs[CommandCosts.CostType.setwarp];
bool withMount = false;
if (args.Command.Name == "setwarpmount")
{
// Check for the gears and pay here, or show error.
withMount = true;
}
int cost = ServerUtilities.config.cmdCosts.costs[withMount ? CommandCosts.CostType.sethomemount : CommandCosts.CostType.setwarp];
int balance = RustyGearUtils.CountRustyGears(isp);
if (cost > 0)
{
@ -575,7 +583,7 @@ namespace AriasServerUtils
return TextCommandResult.Success();
}
}
ServerUtilities.serverWarps.warps[name] = Warp.Create(isp);
ServerUtilities.serverWarps.warps[name] = Warp.Create(isp, withMount);
ServerUtilities.MarkDirty();
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:warp-set", name));
@ -835,5 +843,101 @@ namespace AriasServerUtils
byPlayer.Entity.World.SpawnItemEntity(new ItemStack(byPlayer.Entity.World.GetBlock(new AssetLocation($"soil-{farmlandType}-none"))), blockSel.Position.ToVec3d().Add(0.5, 0.5, 0.5));
}
}
internal static TextCommandResult HandleASUUpdateCmdCostReset(TextCommandCallingArgs args)
{
ServerUtilities.config.cmdCosts = new CommandCosts();
ServerUtilities.config.cmdCosts.SanityCheck();
ServerUtilities.MarkDirty();
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:cost-reset"));
}
private static void UpdateCost(CommandCosts.CostType cost, TextCommandCallingArgs args)
{
if (args[0] is int newCost)
{
// Update the cost
ServerUtilities.config.cmdCosts.costs[cost] = newCost;
ServerUtilities.MarkDirty();
}
}
internal static TextCommandResult HandleASUUpdateCommandCostSpawn(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.spawn, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostRTP(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.rtp, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostBack(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.back, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostSetHome(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.sethome, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostHome(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.home, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostDelHome(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.delhome, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostSetHomeMount(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.sethomemount, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostWarp(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.warp, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostSetWarp(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.setwarp, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostDelWarp(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.delwarp, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
internal static TextCommandResult HandleASUUpdateCommandCostSetWarpMount(TextCommandCallingArgs args)
{
UpdateCost(CommandCosts.CostType.setwarpmount, args);
return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig"));
}
}
}

View file

@ -147,6 +147,7 @@ namespace AriasServerUtils
warp,
setwarp,
delwarp,
setwarpmount,
spawn,
back,
rtp
@ -161,7 +162,10 @@ namespace AriasServerUtils
{ CostType.setwarp, 5 },
{ CostType.warp, 1 },
{ CostType.delwarp, 5 },
{ CostType.spawn, 0 }
{ CostType.setwarpmount, 0 },
{ CostType.spawn, 0 },
{ CostType.back, 0 },
{ CostType.rtp, 0 }
};
/// <summary>

View file

@ -104,7 +104,8 @@ namespace AriasServerUtils
api.ChatCommands.Create("home").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Teleports you to home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleGoHome).WithAlias("h");
api.ChatCommands.Create("delhome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Deletes a home entry").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleDelHome).WithAlias("dh");
api.ChatCommands.Create("homes").RequiresPlayer().WithDescription("Lists your homes").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleListHomes).WithAlias("lh");
api.ChatCommands.Create("sethomemount").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Create a home with the ability to take a mount with you. Costs [undefined] gears.").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSetHome).WithAlias("shm", "shb");
api.ChatCommands.Create("sethomemount").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription($"Create a home with the ability to take a mount with you.").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSetHome).WithAlias("shm", "shb");
api.ChatCommands.Create("setwarpmount").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription($"Create a warp with the ability to take a mount with you.").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleWarpUpdate).WithAlias("swm", "swb");
api.ChatCommands.Create("asu")
.RequiresPrivilege(Privilege.chat)
@ -187,6 +188,102 @@ namespace AriasServerUtils
.WithDescription("Enables or disables dropping soil when breaking farmland")
.HandleWith(Events.HandleUpdateASUFarmlandDrop)
.EndSubCommand()
.BeginSubCommand("costs")
.WithDescription("Update gear costs for various commands")
.BeginSubCommand("reset")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Resets all command costs to factory defaults")
.HandleWith(Events.HandleASUUpdateCmdCostReset)
.EndSubCommand()
.BeginSubCommand("spawn")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update spawn command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.spawn])
)
.HandleWith(Events.HandleASUUpdateCommandCostSpawn)
.EndSubCommand()
.BeginSubCommand("rtp")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update rtp command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.rtp])
)
.HandleWith(Events.HandleASUUpdateCommandCostRTP)
.EndSubCommand()
.BeginSubCommand("back")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update back command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.back])
)
.HandleWith(Events.HandleASUUpdateCommandCostBack)
.EndSubCommand()
.BeginSubCommand("sethome")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update sethome command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.sethome])
)
.HandleWith(Events.HandleASUUpdateCommandCostSetHome)
.EndSubCommand()
.BeginSubCommand("home")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update home command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.home])
)
.HandleWith(Events.HandleASUUpdateCommandCostHome)
.EndSubCommand()
.BeginSubCommand("delhome")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update delhome command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.delhome])
)
.HandleWith(Events.HandleASUUpdateCommandCostDelHome)
.EndSubCommand()
.BeginSubCommand("sethomemount")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update sethomemount command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.sethomemount])
)
.HandleWith(Events.HandleASUUpdateCommandCostSetHomeMount)
.EndSubCommand()
.BeginSubCommand("warp")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update warp command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.warp])
)
.HandleWith(Events.HandleASUUpdateCommandCostWarp)
.EndSubCommand()
.BeginSubCommand("setwarp")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update setwarp command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.setwarp])
)
.HandleWith(Events.HandleASUUpdateCommandCostSetWarp)
.EndSubCommand()
.BeginSubCommand("delwarp")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update delwarp command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.delwarp])
)
.HandleWith(Events.HandleASUUpdateCommandCostDelWarp)
.EndSubCommand()
.BeginSubCommand("setwarpmount")
.RequiresPrivilege(Privilege.controlserver)
.WithDescription("Update setwarpmount command cost")
.WithArgs(
parsers.OptionalInt("cost", CommandCosts.defaults[CommandCosts.CostType.setwarpmount])
)
.HandleWith(Events.HandleASUUpdateCommandCostSetWarpMount)
.EndSubCommand()
.EndSubCommand()
.BeginSubCommand("cooldowns")
.WithDescription("Commands related to all the various cooldowns")
.BeginSubCommand("back")

View file

@ -49,5 +49,6 @@
"psp-ending": "[ASU] PSP Complete",
"cost-insufficient": "You only have {1} rusty gear(s), you need {0}.",
"cost-charged": "You have been charged {0} rusty gear(s)."
"cost-charged": "You have been charged {0} rusty gear(s).",
"cost-reset": "Command costs have been reset"
}

View file

@ -3,8 +3,8 @@
"modid": "ariasserverutils",
"name": "Aria's Server Utilities",
"authors": ["zontreck"],
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 1:16 PM MST",
"version": "1.1.0-dev.7",
"description": "A collection of server utilities\n\nBuild Date: 06-07-2025 @ 1:47 PM MST",
"version": "1.1.0-dev.8",
"dependencies": {
"game": ""
}