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