From e56a123cb8daa3b25fd20777a9f45e2adde87633 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sat, 3 May 2025 12:53:44 -0700 Subject: [PATCH] #5: Add debug to player sleeping percentage --- AriasServerUtils/EventHandler.cs | 11 +++++++++++ AriasServerUtils/ModSystems/ASUClient.cs | 3 ++- AriasServerUtils/ModSystems/ASUServer.cs | 18 +++++++++++------- AriasServerUtils/modinfo.json | 4 ++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/AriasServerUtils/EventHandler.cs b/AriasServerUtils/EventHandler.cs index b284c3d..b4af602 100644 --- a/AriasServerUtils/EventHandler.cs +++ b/AriasServerUtils/EventHandler.cs @@ -7,6 +7,7 @@ using Vintagestory.API.Config; using Vintagestory.API.MathTools; using Vintagestory.API.Server; using Vintagestory.API.Util; +using Vintagestory.GameContent; namespace AriasServerUtils { @@ -577,5 +578,15 @@ namespace AriasServerUtils } return TextCommandResult.Success(sReturn); } + + internal static TextCommandResult HandleSleepyDebug(TextCommandCallingArgs args) + { + EntityBehaviorTiredness sleepy = args.Caller.Entity.GetBehavior(); + if (sleepy != null) + { + sleepy.Tiredness = 100; + } + return TextCommandResult.Success(); + } } } \ No newline at end of file diff --git a/AriasServerUtils/ModSystems/ASUClient.cs b/AriasServerUtils/ModSystems/ASUClient.cs index 2f678b3..3374d49 100644 --- a/AriasServerUtils/ModSystems/ASUClient.cs +++ b/AriasServerUtils/ModSystems/ASUClient.cs @@ -24,10 +24,11 @@ public class ASUModClient : ModSystem { // Time acceleration handler accel = packet.Sleeping; + CAPI.Logger.Notification("Time acceleration: " + packet.Sleeping); if (accel) { - CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 500); + CAPI.World.Calendar.SetTimeSpeedModifier("asu_psp", 1000); } else CAPI.World.Calendar.RemoveTimeSpeedModifier("asu_psp"); } diff --git a/AriasServerUtils/ModSystems/ASUServer.cs b/AriasServerUtils/ModSystems/ASUServer.cs index b00aa66..859f43f 100644 --- a/AriasServerUtils/ModSystems/ASUServer.cs +++ b/AriasServerUtils/ModSystems/ASUServer.cs @@ -238,7 +238,7 @@ namespace AriasServerUtils .HandleWith(Events.HandleASU) .WithDescription("Lists all Aria's Server Utils commands") .EndSubCommand() - /*.BeginSubCommand("test") + .BeginSubCommand("test") .RequiresPlayer() .RequiresPrivilege(Privilege.controlserver) .BeginSubCommand("sleep") @@ -246,12 +246,7 @@ namespace AriasServerUtils .RequiresPrivilege(Privilege.controlserver) .HandleWith(TestSleep) .EndSubCommand() - .BeginSubCommand("calendarspeed") - .RequiresPlayer() - .RequiresPrivilege(Privilege.controlserver) - .HandleWith(TestCalendarSpeed) - .EndSubCommand() - .EndSubCommand()*/ ; + .EndSubCommand(); api.ChatCommands.Create("setwarp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Creates a new server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarpUpdate); api.ChatCommands.Create("warp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithDescription("Warp to the specified server warp").WithArgs(parsers.OptionalWord("name")).HandleWith(Events.HandleWarp); @@ -263,12 +258,16 @@ namespace AriasServerUtils api.ChatCommands.Create("rtp").RequiresPlayer().RequiresPrivilege(Privilege.chat).WithArgs(parsers.OptionalInt("maxDist", defaultValue: -1)).WithDescription("Seeks a position possibly thousands of blocks away to teleport to.").HandleWith(Events.HandleRTP); api.ChatCommands.Create("listcooldowns").RequiresPrivilege(Privilege.chat).WithDescription("Lists the cooldown settings on the server, as well as your own active cooldowns if applicable.").HandleWith(Events.HandleListCooldowns); + + api.ChatCommands.Create("debugasu_sleepy").RequiresPlayer().RequiresPrivilege(Privilege.controlserver).WithDescription("Debugging command to test the sleeping system").HandleWith(Events.HandleSleepyDebug); } private TextCommandResult TestSleep(TextCommandCallingArgs args) { // Initiate the sleep process // Basically run all the same commands as we would on a player in bed + Events.HandleSleepyDebug(args); + OriginalSpeed = API.World.Calendar.CalendarSpeedMul; if (args.Caller.Player is IServerPlayer isp) { @@ -361,6 +360,8 @@ namespace AriasServerUtils }); API.World.Calendar.RemoveTimeSpeedModifier("asu_psp"); + + API.Logger.Notification("Stopping PSP Time Acceleration"); } return; } @@ -422,6 +423,9 @@ namespace AriasServerUtils EntityBehaviorTiredness EBT = bed.MountedBy.GetBehavior(); EBT.IsSleeping = true; + + API.Logger.Notification("Starting PSP Time Acceleration"); + bed.MountedBy.TryUnmount(); // Stand up. We cant trigger the real sleep phase, but all code for starting time accel has been executed. } diff --git a/AriasServerUtils/modinfo.json b/AriasServerUtils/modinfo.json index bc18a83..be4f659 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: 05-3-2025 @ 12:40 PM MST", - "version": "1.0.10-dev.2", + "description": "A collection of server utilities\n\nBuild Date: 05-3-2025 @ 12:53 PM MST", + "version": "1.0.10-dev.3", "dependencies": { "game": "" }