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