diff --git a/Application/Factories/GameServerInstanceFactory.cs b/Application/Factories/GameServerInstanceFactory.cs index dbf4b82b..0e222fbc 100644 --- a/Application/Factories/GameServerInstanceFactory.cs +++ b/Application/Factories/GameServerInstanceFactory.cs @@ -22,7 +22,7 @@ namespace IW4MAdmin.Application.Factories /// /// /// - public GameServerInstanceFactory(ITranslationLookup translationLookup, + public GameServerInstanceFactory(ITranslationLookup translationLookup, IMetaService metaService, IServiceProvider serviceProvider) { @@ -39,7 +39,10 @@ namespace IW4MAdmin.Application.Factories /// public Server CreateServer(ServerConfiguration config, IManager manager) { - return new IW4MServer(config, _translationLookup, _metaService, _serviceProvider, _serviceProvider.GetRequiredService(), _serviceProvider.GetRequiredService>()); + return new IW4MServer(config, + _serviceProvider.GetRequiredService(), _translationLookup, _metaService, + _serviceProvider, _serviceProvider.GetRequiredService(), + _serviceProvider.GetRequiredService>()); } } -} +} \ No newline at end of file diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 72891253..65da123e 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -39,9 +39,11 @@ namespace IW4MAdmin private readonly IServiceProvider _serviceProvider; private readonly IClientNoticeMessageFormatter _messageFormatter; private readonly ILookupCache _serverCache; + private readonly CommandConfiguration _commandConfiguration; public IW4MServer( ServerConfiguration serverConfiguration, + CommandConfiguration commandConfiguration, ITranslationLookup lookup, IMetaService metaService, IServiceProvider serviceProvider, @@ -58,6 +60,7 @@ namespace IW4MAdmin _serviceProvider = serviceProvider; _messageFormatter = messageFormatter; _serverCache = serverCache; + _commandConfiguration = commandConfiguration; } public override async Task OnClientConnected(EFClient clientFromLog) @@ -158,7 +161,7 @@ namespace IW4MAdmin { try { - C = await SharedLibraryCore.Commands.CommandProcessing.ValidateCommand(E, Manager.GetApplicationSettings().Configuration()); + C = await SharedLibraryCore.Commands.CommandProcessing.ValidateCommand(E, Manager.GetApplicationSettings().Configuration(), _commandConfiguration); } catch (CommandException e) diff --git a/SharedLibraryCore/Commands/CommandProcessing.cs b/SharedLibraryCore/Commands/CommandProcessing.cs index 5913be7e..5ebf3632 100644 --- a/SharedLibraryCore/Commands/CommandProcessing.cs +++ b/SharedLibraryCore/Commands/CommandProcessing.cs @@ -11,7 +11,7 @@ namespace SharedLibraryCore.Commands { public class CommandProcessing { - public static async Task ValidateCommand(GameEvent E, ApplicationConfiguration appConfig) + public static async Task ValidateCommand(GameEvent E, ApplicationConfiguration appConfig, CommandConfiguration commandConfig) { var loc = Utilities.CurrentLocalization.LocalizationIndex; var Manager = E.Owner.Manager; @@ -40,7 +40,11 @@ namespace SharedLibraryCore.Commands C.IsBroadcast = isBroadcast; - if (!C.AllowImpersonation && E.ImpersonationOrigin != null) + var allowImpersonation = commandConfig?.Commands?.ContainsKey(C.GetType().Name) ?? false + ? commandConfig.Commands[C.GetType().Name].AllowImpersonation + : C.AllowImpersonation; + + if (!allowImpersonation && E.ImpersonationOrigin != null) { E.ImpersonationOrigin.Tell(loc["COMMANDS_RUN_AS_FAIL"]); throw new CommandException($"Command {C.Name} cannot be run as another client");