refactor: rewrite CommandData as struct
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user