refactor: collapse hooks into nested frozen dictionary

This commit is contained in:
2026-06-04 21:35:57 +02:00
parent 63f5d6e8b6
commit 7cdd8d27c0
3 changed files with 3 additions and 30 deletions
+3 -4
View File
@@ -1,4 +1,4 @@
using System;
using System.Collections.Frozen;
using Vintagestory.API.Common;
using Vintagestory.API.Datastructures;
using Vintagestory.API.Server;
@@ -7,9 +7,8 @@ namespace CommandHook;
public class CommandHookModSystem : ModSystem
{
private ModEntry[] modEntries = Array.Empty<ModEntry>();
private HookEntry[] hashTable = Array.Empty<HookEntry>();
private uint hashTableSize = 0;
private FrozenDictionary<string, FrozenDictionary<string, CommandRegistration>> registrations =
FrozenDictionary<string, FrozenDictionary<string, CommandRegistration>>.Empty;
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
-13
View File
@@ -1,13 +0,0 @@
namespace CommandHook;
public struct HookEntry
{
public readonly string? CommandName; // null = wildcard
public readonly CommandRegistration Registration;
public HookEntry(string? commandName, CommandRegistration registration)
{
CommandName = commandName;
Registration = registration;
}
}
-13
View File
@@ -1,13 +0,0 @@
namespace CommandHook;
public struct ModEntry
{
public readonly string ModId;
public readonly HookEntry[] Hooks;
public ModEntry(string modId, HookEntry[] hooks)
{
ModId = modId;
Hooks = hooks;
}
}