diff --git a/lc-hax/Scripts/Static/Chat.cs b/lc-hax/Scripts/Static/Chat.cs index b6cdc410..7d0cfe00 100644 --- a/lc-hax/Scripts/Static/Chat.cs +++ b/lc-hax/Scripts/Static/Chat.cs @@ -8,38 +8,28 @@ static class Chat { internal static event Action? OnExecuteCommandAttempt; + static IEnumerable CommandTypes { get; } = + Assembly.GetExecutingAssembly() + .GetTypes() + .Where(type => typeof(ICommand).IsAssignableFrom(type)); + static Dictionary Commands { get; } = - Assembly - .GetExecutingAssembly() - .GetTypes() - .Where(type => typeof(ICommand).IsAssignableFrom(type)) - .Where(type => type.GetCustomAttribute() is not null) - .ToDictionary( - type => type.GetCustomAttribute().Syntax, - type => (ICommand)Activator.CreateInstance(type) - ); + Chat.CommandTypes.Where(type => type.GetCustomAttribute() is not null).ToDictionary( + type => type.GetCustomAttribute().Syntax, + type => (ICommand)Activator.CreateInstance(type) + ); static Dictionary DebugCommands { get; } = - Assembly - .GetExecutingAssembly() - .GetTypes() - .Where(type => typeof(ICommand).IsAssignableFrom(type)) - .Where(type => type.GetCustomAttribute() is not null) - .ToDictionary( - type => type.GetCustomAttribute().Syntax, - type => (ICommand)new DebugCommand((ICommand)Activator.CreateInstance(type)) - ); + Chat.CommandTypes.Where(type => type.GetCustomAttribute() is not null).ToDictionary( + type => type.GetCustomAttribute().Syntax, + type => (ICommand)new DebugCommand((ICommand)Activator.CreateInstance(type)) + ); static Dictionary PrivilegeCommands { get; } = - Assembly - .GetExecutingAssembly() - .GetTypes() - .Where(type => typeof(ICommand).IsAssignableFrom(type)) - .Where(type => type.GetCustomAttribute() is not null) - .ToDictionary( - type => type.GetCustomAttribute().Syntax, - type => (ICommand)new PrivilegedCommand((ICommand)Activator.CreateInstance(type)) - ); + Chat.CommandTypes.Where(type => type.GetCustomAttribute() is not null).ToDictionary( + type => type.GetCustomAttribute().Syntax, + type => (ICommand)new PrivilegedCommand((ICommand)Activator.CreateInstance(type)) + ); internal static void Clear() { Helper.HUDManager?.AddTextToChatOnServer(