Add homes list command

This commit is contained in:
zontreck 2025-01-18 14:34:55 -07:00
parent 9522b6d941
commit 93a9a5e8bc
4 changed files with 28 additions and 3 deletions

View file

@ -84,6 +84,7 @@ namespace AriasServerUtils
api.ChatCommands.Create("sethome").RequiresPlayer().WithArgs(parsers.OptionalWord("name")).WithDescription("Creates a home").RequiresPrivilege(Privilege.chat).HandleWith(Events.HandleSetHome);
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);
}
private void OnPlayerDC(IServerPlayer byPlayer)

View file

@ -1,4 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vintagestory.API.Common;
using Vintagestory.API.Config;
using Vintagestory.API.Server;
@ -68,6 +71,26 @@ namespace AriasServerUtils
return TextCommandResult.Success();
}
internal static TextCommandResult HandleListHomes(TextCommandCallingArgs args)
{
if (args.Caller.Player is IServerPlayer isp)
{
PlayerStorage data = ServerUtilities.GetPlayerData(isp);
List<string> lTmp = new List<string>();
foreach (var entry in data.Homes)
{
lTmp.Add(entry.Key);
}
ServerUtilities.SendMessageTo(isp, Lang.Get($"{ServerUtilities.MOD_ID}:home-list", data.Homes.Count, string.Join(", ", lTmp)));
}
return TextCommandResult.Success();
}
internal static TextCommandResult HandleReturnItems(TextCommandCallingArgs args)
{
IPlayer player = args[0] as IPlayer;

View file

@ -15,5 +15,6 @@
"home-no": "No such home exists",
"home-max": "You have reached your max number of homes",
"home-set": "Home saved",
"home-del": "Home deleted"
"home-del": "Home deleted",
"home-list": "You have [{0}] home(s)\n\n{1}"
}

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:17 PM",
"version": "1.0.0-dev.6",
"description": "A collection of server utilities\n\nBuild Date: 01-18-2025 @ 02:22 PM",
"version": "1.0.0-dev.7",
"dependencies": {
"game": ""
}