refactor: rewrite CommandData as struct
This commit is contained in:
@@ -2,19 +2,18 @@ using Vintagestory.API.Server;
|
|||||||
|
|
||||||
namespace CommandHook;
|
namespace CommandHook;
|
||||||
|
|
||||||
public class CommandData
|
public struct CommandData
|
||||||
{
|
{
|
||||||
public IServerPlayer? Sender { get; }
|
public readonly IServerPlayer? Sender;
|
||||||
public string FullCommand { get; }
|
public readonly string FullCommand;
|
||||||
public bool IsPlayerCommand { get; }
|
public readonly bool IsPlayerCommand;
|
||||||
public bool Cancel { get; set; }
|
public bool Cancel;
|
||||||
|
|
||||||
|
public CommandData(IServerPlayer? sender, string fullCommand)
|
||||||
public CommandData(IServerPlayer sender, string fullCommand)
|
|
||||||
{
|
{
|
||||||
Sender = sender;
|
Sender = sender;
|
||||||
IsPlayerCommand = Sender != null;
|
FullCommand = fullCommand.Length > 0 ? fullCommand.Trim() : string.Empty;
|
||||||
FullCommand = fullCommand?.Trim() ?? string.Empty;
|
IsPlayerCommand = sender != null;
|
||||||
Cancel = false;
|
Cancel = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,14 @@
|
|||||||
using Vintagestory.API.Server;
|
using Vintagestory.API.Server;
|
||||||
using Vintagestory.API.Common;
|
using Vintagestory.API.Common;
|
||||||
|
|
||||||
namespace CommandHook;
|
namespace CommandHook;
|
||||||
|
|
||||||
public class CommandHookModSystem : ModSystem
|
public class CommandHookModSystem : ModSystem
|
||||||
{
|
{
|
||||||
|
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||||
public override bool ShouldLoad(EnumAppSide forSide)
|
|
||||||
{
|
|
||||||
return forSide == EnumAppSide.Server;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void StartServerSide(ICoreServerAPI api)
|
public override void StartServerSide(ICoreServerAPI api)
|
||||||
{
|
{
|
||||||
Mod.Logger.Notification("Loaded");
|
Mod.Logger.Notification("[CommandHook] Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user