Compare commits

3 Commits
5 changed files with 36 additions and 44 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;
}
}
+8 -6
View File
@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin\$(Configuration)\Mods\mod</OutputPath>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
@@ -50,16 +52,16 @@
</Reference>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Content Include="modinfo.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Content Include="modicon.png" Condition="Exists('modicon.png')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</ItemGroup>
</Project>
+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");
}
}
+7 -10
View File
@@ -1,15 +1,12 @@
{
"$schema": "https://moddbcdn.vintagestory.at/schema/modinfo.latest.json",
"type": "Code",
"type": "code",
"modid": "commandhook",
"name": "CommandHook",
"authors": [
"anth64"
],
"description": "A server-side API for routing and overriding vanilla commands.",
"version": "0.0.0",
"description": "Exposes server command events for other mods to hook into.",
"authors": ["anth64"],
"version": "0.1.0",
"side": "Server",
"dependencies": {
"game": "1.21.0"
},
"side": "Server"
"game": "1.22.3"
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>