From ba9d4d992bcbc4995c47486d73cd3000ffb31d23 Mon Sep 17 00:00:00 2001 From: anth64 Date: Mon, 29 Jun 2026 07:31:51 +0200 Subject: [PATCH] feat: hook into land claim commands via CommandHook --- ClaimLink/ClaimLinkModSystem.cs | 22 +++++++++++++++++++++- ClaimLink/LandCommandListener.cs | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 ClaimLink/LandCommandListener.cs diff --git a/ClaimLink/ClaimLinkModSystem.cs b/ClaimLink/ClaimLinkModSystem.cs index 0e32481..37c11be 100644 --- a/ClaimLink/ClaimLinkModSystem.cs +++ b/ClaimLink/ClaimLinkModSystem.cs @@ -1,7 +1,27 @@ -using Vintagestory.API.Common; +using CommandHook; +using Vintagestory.API.Common; +using Vintagestory.API.Server; namespace ClaimLink; public class ClaimLinkModSystem : ModSystem { + internal ClaimLinkCommandListener? cmdListener; + + public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server; + + public override void StartServerSide(ICoreServerAPI api) + { + cmdListener = new ClaimLinkCommandListener(); + CommandHookModSystem.Register(cmdListener); + } + + public override void Dispose() + { + if (cmdListener == null) + return; + + CommandHookModSystem.Unregister(cmdListener); + } } + diff --git a/ClaimLink/LandCommandListener.cs b/ClaimLink/LandCommandListener.cs new file mode 100644 index 0000000..aff0e6b --- /dev/null +++ b/ClaimLink/LandCommandListener.cs @@ -0,0 +1,24 @@ +using Vintagestory.API.Common; +using System.Collections.Generic; +using CommandHook; + +namespace ClaimLink; + +public class ClaimLinkCommandListener : ICommandHookListener +{ + public string ModId => "claimlink"; + + public IReadOnlyList Commands => new[] { "land" }; + + public CommandRegistration Registration => new(Before, After); + + private TextCommandResult? Before(TextCommandCallingArgs args) + { + return null; + } + + private void After(TextCommandCallingArgs args, TextCommandResult result) + { + } +} +