diff --git a/AriasServerUtils/ASUModSystem.cs b/AriasServerUtils/ASUModSystem.cs index 1be9cf4..2c2a0b4 100644 --- a/AriasServerUtils/ASUModSystem.cs +++ b/AriasServerUtils/ASUModSystem.cs @@ -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) diff --git a/AriasServerUtils/EventHandler.cs b/AriasServerUtils/EventHandler.cs index 987f3da..6858333 100644 --- a/AriasServerUtils/EventHandler.cs +++ b/AriasServerUtils/EventHandler.cs @@ -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 lTmp = new List(); + 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; diff --git a/AriasServerUtils/assets/ariasserverutils/lang/en.json b/AriasServerUtils/assets/ariasserverutils/lang/en.json index b78a299..c756cf8 100644 --- a/AriasServerUtils/assets/ariasserverutils/lang/en.json +++ b/AriasServerUtils/assets/ariasserverutils/lang/en.json @@ -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}" } diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json index 0559972..b356ca5 100644 --- a/AriasServerUtils/modinfo.json +++ b/AriasServerUtils/modinfo.json @@ -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": "" }