refactor: rewrite CommandData as struct

This commit is contained in:
2026-06-02 22:54:34 +02:00
parent d3c7bc87cb
commit ce851148f0
2 changed files with 13 additions and 20 deletions
+8 -9
View File
@@ -2,19 +2,18 @@ using Vintagestory.API.Server;
namespace CommandHook;
public class CommandData
public struct CommandData
{
public IServerPlayer? Sender { get; }
public string FullCommand { get; }
public bool IsPlayerCommand { get; }
public bool Cancel { get; set; }
public readonly IServerPlayer? Sender;
public readonly string FullCommand;
public readonly bool IsPlayerCommand;
public bool Cancel;
public CommandData(IServerPlayer sender, string fullCommand)
public CommandData(IServerPlayer? sender, string fullCommand)
{
Sender = sender;
IsPlayerCommand = Sender != null;
FullCommand = fullCommand?.Trim() ?? string.Empty;
FullCommand = fullCommand.Length > 0 ? fullCommand.Trim() : string.Empty;
IsPlayerCommand = sender != null;
Cancel = false;
}
}
+3 -9
View File
@@ -1,20 +1,14 @@
using Vintagestory.API.Server;
using Vintagestory.API.Server;
using Vintagestory.API.Common;
namespace CommandHook;
public class CommandHookModSystem : ModSystem
{
public override bool ShouldLoad(EnumAppSide forSide)
{
return forSide == EnumAppSide.Server;
}
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
public override void StartServerSide(ICoreServerAPI api)
{
Mod.Logger.Notification("Loaded");
Mod.Logger.Notification("[CommandHook] Loaded");
}
}