use default settings for maps and quick messages config (remove from IW4MAdminSettings)
This commit is contained in:
parent
ed8067a4a2
commit
31ee71260a
@ -353,9 +353,7 @@ namespace IW4MAdmin.Application
|
||||
|
||||
_appConfig.AutoMessages = defaultConfig.AutoMessages;
|
||||
_appConfig.GlobalRules = defaultConfig.GlobalRules;
|
||||
_appConfig.Maps = defaultConfig.Maps;
|
||||
_appConfig.DisallowedClientNames = defaultConfig.DisallowedClientNames;
|
||||
_appConfig.QuickMessages = defaultConfig.QuickMessages;
|
||||
|
||||
//if (newConfig.Servers == null)
|
||||
{
|
||||
@ -396,6 +394,18 @@ namespace IW4MAdmin.Application
|
||||
await ConfigHandler.Save();
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
if (_appConfig.Maps != null)
|
||||
{
|
||||
_appConfig.Maps = null;
|
||||
}
|
||||
|
||||
if (_appConfig.QuickMessages != null)
|
||||
{
|
||||
_appConfig.QuickMessages = null;
|
||||
}
|
||||
#pragma warning restore 618
|
||||
|
||||
var validator = new ApplicationConfigurationValidator();
|
||||
var validationResult = validator.Validate(_appConfig);
|
||||
|
||||
@ -410,7 +420,7 @@ namespace IW4MAdmin.Application
|
||||
|
||||
foreach (var serverConfig in _appConfig.Servers)
|
||||
{
|
||||
Migration.ConfigurationMigration.ModifyLogPath020919(serverConfig);
|
||||
ConfigurationMigration.ModifyLogPath020919(serverConfig);
|
||||
|
||||
if (serverConfig.RConParserVersion == null || serverConfig.EventParserVersion == null)
|
||||
{
|
||||
|
@ -435,8 +435,8 @@
|
||||
"Name": "oilrig"
|
||||
},
|
||||
{
|
||||
"Name": "Village",
|
||||
"Alias": "co_hunted"
|
||||
"Alias": "Village",
|
||||
"Name": "co_hunted"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -613,7 +613,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
try
|
||||
{
|
||||
message = Manager.GetApplicationSettings().Configuration()
|
||||
message = _serviceProvider.GetRequiredService<DefaultSettings>()
|
||||
.QuickMessages
|
||||
.First(_qm => _qm.Game == GameName)
|
||||
.Messages[E.Data.Substring(1)];
|
||||
@ -1139,7 +1139,13 @@ namespace IW4MAdmin
|
||||
Manager.GetApplicationSettings().Configuration().ContactUri = Website;
|
||||
}
|
||||
|
||||
InitializeMaps();
|
||||
var defaultConfig = _serviceProvider.GetRequiredService<DefaultSettings>();
|
||||
var gameMaps = defaultConfig?.Maps?.FirstOrDefault(map => map.Game == GameName);
|
||||
|
||||
if (gameMaps != null)
|
||||
{
|
||||
Maps.AddRange(gameMaps.Maps);
|
||||
}
|
||||
|
||||
WorkingDirectory = basepath.Value;
|
||||
this.Hostname = hostname;
|
||||
|
@ -333,6 +333,8 @@ namespace IW4MAdmin.Application
|
||||
// setup the static resources (config/master api/translations)
|
||||
var serviceCollection = new ServiceCollection();
|
||||
var appConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings");
|
||||
var defaultConfigHandler = new BaseConfigurationHandler<DefaultSettings>("DefaultSettings");
|
||||
var defaultConfig = defaultConfigHandler.Configuration();
|
||||
var appConfig = appConfigHandler.Configuration();
|
||||
var masterUri = Utilities.IsDevelopment
|
||||
? new Uri("http://127.0.0.1:8080")
|
||||
@ -361,6 +363,7 @@ namespace IW4MAdmin.Application
|
||||
|
||||
serviceCollection
|
||||
.AddBaseLogger(appConfig)
|
||||
.AddSingleton(defaultConfig)
|
||||
.AddSingleton<IServiceCollection>(_serviceProvider => serviceCollection)
|
||||
.AddSingleton<IConfigurationHandler<DefaultSettings>, BaseConfigurationHandler<DefaultSettings>>()
|
||||
.AddSingleton((IConfigurationHandler<ApplicationConfiguration>) appConfigHandler)
|
||||
|
@ -24,14 +24,14 @@ namespace Stats.Helpers
|
||||
{
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ApplicationConfiguration _appConfig;
|
||||
private readonly DefaultSettings _defaultSettings;
|
||||
private List<EFServer> serverCache;
|
||||
|
||||
public ChatResourceQueryHelper(ILogger<ChatResourceQueryHelper> logger, IDatabaseContextFactory contextFactory, ApplicationConfiguration appConfig)
|
||||
public ChatResourceQueryHelper(ILogger<ChatResourceQueryHelper> logger, IDatabaseContextFactory contextFactory, DefaultSettings defaultSettings)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_logger = logger;
|
||||
_appConfig = appConfig;
|
||||
_defaultSettings = defaultSettings;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@ -106,20 +106,22 @@ namespace Stats.Helpers
|
||||
{
|
||||
message.IsHidden = serverCache.Any(server => server.ServerId == message.ServerId && server.IsPasswordProtected);
|
||||
|
||||
if (message.Message.IsQuickMessage())
|
||||
if (!message.Message.IsQuickMessage())
|
||||
{
|
||||
try
|
||||
{
|
||||
var quickMessages = _appConfig
|
||||
.QuickMessages
|
||||
.First(_qm => _qm.Game == message.GameName);
|
||||
message.Message = quickMessages.Messages[message.Message.Substring(1)];
|
||||
message.IsQuickMessage = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
message.Message = message.Message.Substring(1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var quickMessages = _defaultSettings
|
||||
.QuickMessages
|
||||
.First(_qm => _qm.Game == message.GameName);
|
||||
message.Message = quickMessages.Messages[message.Message.Substring(1)];
|
||||
message.IsQuickMessage = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
message.Message = message.Message.Substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using static Data.Models.Client.EFClient;
|
||||
|
||||
namespace SharedLibraryCore.Configuration
|
||||
@ -149,10 +150,13 @@ namespace SharedLibraryCore.Configuration
|
||||
[ConfigurationIgnore] public int MinimumNameLength { get; set; } = 3;
|
||||
[ConfigurationIgnore] public string Id { get; set; }
|
||||
[ConfigurationIgnore] public string SubscriptionId { get; set; }
|
||||
[Obsolete("Moved to DefaultSettings")]
|
||||
[ConfigurationIgnore] public MapConfiguration[] Maps { get; set; }
|
||||
[Obsolete("Moved to DefaultSettings")]
|
||||
[ConfigurationIgnore] public QuickMessageConfiguration[] QuickMessages { get; set; }
|
||||
|
||||
[ConfigurationIgnore]
|
||||
[JsonIgnore]
|
||||
public string WebfrontUrl => string.IsNullOrEmpty(ManualWebfrontUrl)
|
||||
? WebfrontBindUrl?.Replace("0.0.0.0", "127.0.0.1")
|
||||
: ManualWebfrontUrl;
|
||||
|
@ -251,17 +251,6 @@ namespace SharedLibraryCore
|
||||
/// </summary>
|
||||
abstract public void InitializeTokens();
|
||||
|
||||
/// <summary>
|
||||
/// Read the map configuration
|
||||
/// </summary>
|
||||
protected void InitializeMaps()
|
||||
{
|
||||
Maps = new List<Map>();
|
||||
var gameMaps = Manager.GetApplicationSettings().Configuration().Maps.FirstOrDefault(m => m.Game == GameName);
|
||||
if (gameMaps != null)
|
||||
Maps.AddRange(gameMaps.Maps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the messages to be broadcasted
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user