From 1f5458b8b1b86259afccf9956825d41290e1bcb3 Mon Sep 17 00:00:00 2001 From: zontreck Date: Mon, 20 Jan 2025 04:10:17 -0700 Subject: [PATCH] Begin to add player sleeping percentage --- AriasServerUtils/ASUModSystem.cs | 10 ++++++++++ AriasServerUtils/EventHandler.cs | 8 ++++++++ AriasServerUtils/Globals.cs | 1 + AriasServerUtils/modinfo.json | 4 ++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/AriasServerUtils/ASUModSystem.cs b/AriasServerUtils/ASUModSystem.cs index 6ffab7c..ed22f3b 100644 --- a/AriasServerUtils/ASUModSystem.cs +++ b/AriasServerUtils/ASUModSystem.cs @@ -5,6 +5,7 @@ using Vintagestory.API.Client; using Vintagestory.API.Common; using Vintagestory.API.Common.Entities; using Vintagestory.API.Config; +using Vintagestory.API.MathTools; using Vintagestory.API.Server; using Vintagestory.GameContent; @@ -128,6 +129,14 @@ namespace AriasServerUtils .WithDescription("Max number of back positions cached for players") .HandleWith(Events.HandleUpdateASUMaxBack) .EndSubCommand() + .BeginSubCommand("playerSleepingPercentage") + .RequiresPrivilege(Privilege.controlserver) + .WithArgs( + parsers.OptionalIntRange("psp", 1, 100, 50) + ) + .WithDescription("Percentage of players required to sleep before sleeping through the night") + .HandleWith(Events.HandleUpdateASUPSP) + .EndSubCommand() .EndSubCommand() .BeginSubCommand("help") .RequiresPrivilege(Privilege.chat) @@ -143,6 +152,7 @@ namespace AriasServerUtils api.ChatCommands.Create("back").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Returns you to the last location you were at").HandleWith(Events.HandleBack); } + public static void NewBackCacheForPlayer(IServerPlayer player) { backCaches.AddPosition(player.PlayerName, PlayerPosition.from(player.Entity)); diff --git a/AriasServerUtils/EventHandler.cs b/AriasServerUtils/EventHandler.cs index 1e75408..4731723 100644 --- a/AriasServerUtils/EventHandler.cs +++ b/AriasServerUtils/EventHandler.cs @@ -253,6 +253,14 @@ namespace AriasServerUtils return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig")); } + internal static TextCommandResult HandleUpdateASUPSP(TextCommandCallingArgs args) + { + if (args[0] is int psp) ServerUtilities.config.PlayerSleepingPercentage = psp; + ServerUtilities.MarkDirty(); + + return TextCommandResult.Success(Lang.Get($"{ServerUtilities.MOD_ID}:updatedconfig")); + } + internal static TextCommandResult HandleWarp(TextCommandCallingArgs args) { string name = "default"; diff --git a/AriasServerUtils/Globals.cs b/AriasServerUtils/Globals.cs index df5a653..223b195 100644 --- a/AriasServerUtils/Globals.cs +++ b/AriasServerUtils/Globals.cs @@ -17,6 +17,7 @@ namespace AriasServerUtils public bool AdminsBypassMaxHomes { get; set; } = true; public bool onlyAdminsCreateWarps { get; set; } = true; public int MaxBackCache { get; set; } = 10; + public int PlayerSleepingPercentage { get; set; } = 50; public PlayerPosition Spawn { get; set; } diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json index ef9e6f3..8b8b488 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 @ 09:22 PM", - "version": "1.0.3", + "description": "A collection of server utilities\n\nBuild Date: 01-20-2025 @ 12:38 AM MST", + "version": "1.0.4-dev.1", "dependencies": { "game": "" }