feat: add registration dictionary and Register method
This commit is contained in:
@@ -1,14 +1,27 @@
|
|||||||
using Vintagestory.API.Server;
|
using System.Collections.Generic;
|
||||||
using Vintagestory.API.Common;
|
using Vintagestory.API.Common;
|
||||||
|
using Vintagestory.API.Server;
|
||||||
|
|
||||||
namespace CommandHook;
|
namespace CommandHook;
|
||||||
|
|
||||||
public class CommandHookModSystem : ModSystem
|
public class CommandHookModSystem : ModSystem
|
||||||
{
|
{
|
||||||
|
private readonly Dictionary<string, List<CommandRegistration>> _registrations = new();
|
||||||
|
|
||||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||||
|
|
||||||
public override void StartServerSide(ICoreServerAPI api)
|
public override void StartServerSide(ICoreServerAPI api)
|
||||||
{
|
{
|
||||||
Mod.Logger.Notification("[CommandHook] Loaded");
|
Mod.Logger.Notification("[CommandHook] Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Register(string modId, CommandRegistration registration)
|
||||||
|
{
|
||||||
|
if (!_registrations.TryGetValue(modId, out var list))
|
||||||
|
{
|
||||||
|
list = new List<CommandRegistration>();
|
||||||
|
_registrations[modId] = list;
|
||||||
|
}
|
||||||
|
list.Add(registration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user