diff --git a/src/ChatServer/ExDbConnector/Program.cs b/src/ChatServer/ExDbConnector/Program.cs index bf9c2e6fe..8853e88d7 100644 --- a/src/ChatServer/ExDbConnector/Program.cs +++ b/src/ChatServer/ExDbConnector/Program.cs @@ -56,7 +56,7 @@ internal static async Task Main(string[] args) // To make the chat server use our configured encryption key, we need to trick a bit. We add an endpoint with a special client version which is defined in the plugin. var configuration = new ChatServerSettings(); configuration.Endpoints.Add(new ChatServerEndpoint { ClientVersion = ConfigurableNetworkEncryptionPlugIn.Version, NetworkPort = chatServerListenerPort }); - var pluginManager = new PlugInManager(null, loggerFactory, serviceContainer); + var pluginManager = new PlugInManager(null, loggerFactory, serviceContainer, null); pluginManager.DiscoverAndRegisterPlugInsOf(); var chatServer = new ChatServer(addressResolver, loggerFactory, pluginManager); chatServer.Initialize(configuration); diff --git a/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs index 65b5ae2f2..47e7d4b79 100644 --- a/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs +++ b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs @@ -15,14 +15,26 @@ namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions; /// [Guid("E95A0292-B3B4-4E8C-AC5A-7F3DB4F01A37")] [PlugIn(nameof(BlessJewelConsumeHandlerPlugIn), "Plugin which handles the jewel of bless consumption.")] -public class BlessJewelConsumeHandlerPlugIn : ItemModifyConsumeHandlerPlugIn +public class BlessJewelConsumeHandlerPlugIn : ItemModifyConsumeHandlerPlugIn, ISupportCustomConfiguration { /// public override ItemIdentifier Key => ItemConstants.JewelOfBless; + /// + /// Gets or sets the configuration. + /// + public BlessJewelConsumeHandlerPlugInConfiguration? Configuration { get; set; } + /// protected override bool ModifyItem(Item item, IContext persistenceContext) { + if (this.Configuration?.RepairTargetItems.Contains(item.Definition!) is true + && item.Durability < item.GetMaximumDurabilityOfOnePiece()) + { + item.Durability = item.GetMaximumDurabilityOfOnePiece(); + return true; + } + if (!item.CanLevelBeUpgraded()) { return false; @@ -37,6 +49,7 @@ protected override bool ModifyItem(Item item, IContext persistenceContext) level++; item.Level = level; + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return true; } } \ No newline at end of file diff --git a/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs new file mode 100644 index 000000000..23994c22a --- /dev/null +++ b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs @@ -0,0 +1,18 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions; + +using MUnique.OpenMU.DataModel.Configuration.Items; + +/// +/// The configuration for the . +/// +public class BlessJewelConsumeHandlerPlugInConfiguration +{ + /// + /// Gets or sets the items which can be repaired by consuming a bless on them. + /// + public ICollection RepairTargetItems { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs b/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs index 0d9738147..561d372db 100644 --- a/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs +++ b/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs @@ -62,6 +62,7 @@ protected override bool ModifyItem(Item item, IContext persistenceContext) if (this._randomizer.NextRandomBool(percent)) { item.Level++; + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return true; // true doesn't mean that it was successful, just that the consumption happened. } diff --git a/src/Network/Analyzer/MainForm.cs b/src/Network/Analyzer/MainForm.cs index 1d135fe01..e933f2dda 100644 --- a/src/Network/Analyzer/MainForm.cs +++ b/src/Network/Analyzer/MainForm.cs @@ -49,7 +49,7 @@ public MainForm() this.InitializeComponent(); var serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(ILoggerFactory), new NullLoggerFactory()); - this._plugInManager = new PlugInManager(null, new NullLoggerFactory(), serviceContainer); + this._plugInManager = new PlugInManager(null, new NullLoggerFactory(), serviceContainer, null); this._plugInManager.DiscoverAndRegisterPlugIns(); this.clientBindingSource.DataSource = this._proxiedConnections; this.connectedClientsListBox.DisplayMember = nameof(ICapturedConnection.Name); diff --git a/src/Persistence/ByDataSourceReferenceHandler.cs b/src/Persistence/ByDataSourceReferenceHandler.cs new file mode 100644 index 000000000..1e507f562 --- /dev/null +++ b/src/Persistence/ByDataSourceReferenceHandler.cs @@ -0,0 +1,34 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence; + +using System.Text.Json.Serialization; +using MUnique.OpenMU.DataModel.Configuration; + +/// +/// A reference handler which uses a to resolve references. +/// +public class ByDataSourceReferenceHandler : ReferenceHandler +{ + /// + /// The data source. + /// + private readonly IDataSource _dataSource; + + /// + /// Initializes a new instance of the class. + /// + /// The data source. + public ByDataSourceReferenceHandler(IDataSource dataSource) + { + this._dataSource = dataSource; + } + + /// + public override ReferenceResolver CreateResolver() + { + return new ByDataSourceReferenceResolver(this._dataSource); + } +} \ No newline at end of file diff --git a/src/Persistence/ByDataSourceReferenceResolver.cs b/src/Persistence/ByDataSourceReferenceResolver.cs new file mode 100644 index 000000000..fedf7a1fa --- /dev/null +++ b/src/Persistence/ByDataSourceReferenceResolver.cs @@ -0,0 +1,54 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence; + +using System.Text.Json.Serialization; +using MUnique.OpenMU.DataModel.Configuration; + +/// +/// A reference resolver which uses a to resolve references. +/// +public class ByDataSourceReferenceResolver : ReferenceResolver +{ + /// + /// The data source. + /// + private readonly IDataSource _dataSource; + + /// + /// Initializes a new instance of the class. + /// + /// The data source. + public ByDataSourceReferenceResolver(IDataSource dataSource) + { + this._dataSource = dataSource; + } + + /// + public override void AddReference(string referenceId, object value) + { + // do nothing here, because the data source is the source of truth. + } + + /// + public override string GetReference(object value, out bool alreadyExists) + { + if (value is IIdentifiable identifiable) + { + alreadyExists = this._dataSource.Get(identifiable.Id) is { }; + return identifiable.Id.ToString(); + } + + alreadyExists = false; + return string.Empty; + } + + /// + public override object ResolveReference(string referenceId) + { + var id = Guid.Parse(referenceId); + return this._dataSource.Get(id) ?? throw new KeyNotFoundException($"Reference with id '{referenceId}' not found."); + } +} \ No newline at end of file diff --git a/src/Persistence/Initialization/DataInitializationBase.cs b/src/Persistence/Initialization/DataInitializationBase.cs index c7b229824..f29fe2390 100644 --- a/src/Persistence/Initialization/DataInitializationBase.cs +++ b/src/Persistence/Initialization/DataInitializationBase.cs @@ -120,9 +120,10 @@ public async Task CreateInitialDataAsync(byte numberOfGameServers, bool createTe // should never happen, but the access to the GameServer type is a trick to load the assembly into the current domain. } + var referenceHandler = new ByDataSourceReferenceHandler(new GameConfigurationDataSource(this._loggerFactory.CreateLogger(), this._persistenceContextProvider)); var serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(IPersistenceContextProvider), this._persistenceContextProvider); - var plugInManager = new PlugInManager(null, this._loggerFactory, serviceContainer); + var plugInManager = new PlugInManager(null, this._loggerFactory, serviceContainer, referenceHandler); plugInManager.DiscoverAndRegisterPlugIns(); plugInManager.KnownPlugInTypes.ForEach(plugInType => { @@ -136,32 +137,32 @@ public async Task CreateInitialDataAsync(byte numberOfGameServers, bool createTe if (plugInType == typeof(ResetFeaturePlugIn)) { plugInConfiguration.IsActive = false; - plugInConfiguration.SetConfiguration(new ResetConfiguration()); + plugInConfiguration.SetConfiguration(new ResetConfiguration(), referenceHandler); } if (plugInType == typeof(ChaosCastleStartPlugIn)) { - plugInConfiguration.SetConfiguration(ChaosCastleStartConfiguration.Default); + plugInConfiguration.SetConfiguration(ChaosCastleStartConfiguration.Default, referenceHandler); } if (plugInType == typeof(GoldenInvasionPlugIn)) { - plugInConfiguration.SetConfiguration(PeriodicInvasionConfiguration.DefaultGoldenInvasion); + plugInConfiguration.SetConfiguration(PeriodicInvasionConfiguration.DefaultGoldenInvasion, referenceHandler); } if (plugInType == typeof(RedDragonInvasionPlugIn)) { - plugInConfiguration.SetConfiguration(PeriodicInvasionConfiguration.DefaultRedDragonInvasion); + plugInConfiguration.SetConfiguration(PeriodicInvasionConfiguration.DefaultRedDragonInvasion, referenceHandler); } if (plugInType == typeof(HappyHourPlugIn)) { - plugInConfiguration.SetConfiguration(HappyHourConfiguration.Default); + plugInConfiguration.SetConfiguration(HappyHourConfiguration.Default, referenceHandler); } if (plugInType == typeof(MuHelperFeaturePlugIn)) { - plugInConfiguration.SetConfiguration(new MuHelperConfiguration()); + plugInConfiguration.SetConfiguration(new MuHelperConfiguration(), referenceHandler); } // We don't move the player anymore by his request. This was usually requested after a player performed a skill. diff --git a/src/PlugIns/PlugInConfigurationExtensions.cs b/src/PlugIns/PlugInConfigurationExtensions.cs index 14220bdbf..0c7596829 100644 --- a/src/PlugIns/PlugInConfigurationExtensions.cs +++ b/src/PlugIns/PlugInConfigurationExtensions.cs @@ -5,6 +5,7 @@ namespace MUnique.OpenMU.PlugIns; using System.Text.Json; +using System.Text.Json.Serialization; /// /// Extension methods for the plugin configuration. @@ -16,10 +17,11 @@ public static class PlugInConfigurationExtensions /// /// The custom configuration type. /// The configuration. + /// The reference handler. /// /// The custom configuration as . /// - public static T? GetConfiguration(this PlugInConfiguration configuration) + public static T? GetConfiguration(this PlugInConfiguration configuration, ReferenceHandler? referenceHandler) where T : class { if (string.IsNullOrWhiteSpace(configuration.CustomConfiguration)) @@ -27,7 +29,12 @@ public static class PlugInConfigurationExtensions return default; } - return JsonSerializer.Deserialize(configuration.CustomConfiguration); + var options = new JsonSerializerOptions + { + ReferenceHandler = referenceHandler, + }; + + return JsonSerializer.Deserialize(configuration.CustomConfiguration, options); } /// @@ -35,17 +42,23 @@ public static class PlugInConfigurationExtensions /// /// The configuration. /// Type of the configuration. + /// The reference handler. /// /// The custom configuration as the given specified type. /// - public static object? GetConfiguration(this PlugInConfiguration configuration, Type configurationType) + public static object? GetConfiguration(this PlugInConfiguration configuration, Type configurationType, ReferenceHandler? referenceHandler) { if (string.IsNullOrWhiteSpace(configuration.CustomConfiguration)) { return default; } - return JsonSerializer.Deserialize(configuration.CustomConfiguration, configurationType); + var options = new JsonSerializerOptions + { + ReferenceHandler = referenceHandler, + }; + + return JsonSerializer.Deserialize(configuration.CustomConfiguration, configurationType, options); } /// @@ -54,9 +67,10 @@ public static class PlugInConfigurationExtensions /// The custom configuration type. /// The plug in configuration. /// The configuration. - public static void SetConfiguration(this PlugInConfiguration plugInConfiguration, T configuration) + /// The reference handler. + public static void SetConfiguration(this PlugInConfiguration plugInConfiguration, T configuration, ReferenceHandler? referenceHandler) { - plugInConfiguration.CustomConfiguration = JsonSerializer.Serialize(configuration, new JsonSerializerOptions { WriteIndented = true }); + plugInConfiguration.CustomConfiguration = JsonSerializer.Serialize(configuration, new JsonSerializerOptions { WriteIndented = true, ReferenceHandler = referenceHandler }); } /// @@ -64,8 +78,12 @@ public static void SetConfiguration(this PlugInConfiguration plugInConfigurat /// /// The plug in configuration. /// The configuration. - public static void SetConfiguration(this PlugInConfiguration plugInConfiguration, object configuration) + /// The reference handler. + public static void SetConfiguration(this PlugInConfiguration plugInConfiguration, object configuration, ReferenceHandler? referenceHandler) { - plugInConfiguration.CustomConfiguration = JsonSerializer.Serialize(configuration, configuration.GetType(), new JsonSerializerOptions { WriteIndented = true }); + plugInConfiguration.CustomConfiguration = JsonSerializer.Serialize( + configuration, + configuration.GetType(), + new JsonSerializerOptions { WriteIndented = true, ReferenceHandler = referenceHandler }); } } \ No newline at end of file diff --git a/src/PlugIns/PlugInContainerBase.cs b/src/PlugIns/PlugInContainerBase.cs index 78e9c20e4..bd7b40975 100644 --- a/src/PlugIns/PlugInContainerBase.cs +++ b/src/PlugIns/PlugInContainerBase.cs @@ -207,7 +207,7 @@ private void OnPlugInConfigurationChanged(object? sender, PlugInConfigurationCha is { } configSupportInterface) { var configType = configSupportInterface.GenericTypeArguments[0]; - var typedCustomConfiguration = e.Configuration.GetConfiguration(configType); + var typedCustomConfiguration = e.Configuration.GetConfiguration(configType, this.Manager.CustomConfigReferenceHandler); configSupportInterface .GetProperty(nameof(ISupportCustomConfiguration.Configuration)) ?.SetMethod diff --git a/src/PlugIns/PlugInManager.cs b/src/PlugIns/PlugInManager.cs index 7fd470c2c..8ab52519a 100644 --- a/src/PlugIns/PlugInManager.cs +++ b/src/PlugIns/PlugInManager.cs @@ -8,6 +8,7 @@ namespace MUnique.OpenMU.PlugIns; using System.ComponentModel.Design; using System.Reflection; using System.Runtime.InteropServices; +using System.Text.Json.Serialization; using Microsoft.CodeAnalysis.CSharp; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -32,7 +33,7 @@ public class PlugInManager /// The configurations. /// The logger factory. /// The service provider. - public PlugInManager(ICollection? configurations, ILoggerFactory loggerFactory, IServiceProvider? serviceProvider) + public PlugInManager(ICollection? configurations, ILoggerFactory loggerFactory, IServiceProvider? serviceProvider, ReferenceHandler? customConfigReferenceHandler) { _ = typeof(Nito.AsyncEx.AsyncReaderWriterLock); // Ensure Nito.AsyncEx.Coordination is loaded so it will be available in proxy generation. @@ -41,6 +42,8 @@ public PlugInManager(ICollection? configurations, ILoggerFa this._serviceContainer.AddService(typeof(PlugInManager), this); this._serviceContainer.AddService(typeof(ILoggerFactory), loggerFactory); + this.CustomConfigReferenceHandler = customConfigReferenceHandler; + if (configurations is not null) { this.DiscoverAndRegisterPlugIns(); @@ -75,6 +78,11 @@ public PlugInManager(ICollection? configurations, ILoggerFa /// public IEnumerable KnownPlugInTypes => this._knownPlugIns.Values; + /// + /// Gets the reference handler for references in custom plugin configurations. + /// + public ReferenceHandler? CustomConfigReferenceHandler { get; } + /// /// Discovers and registers all plug ins of all loaded assemblies. /// diff --git a/src/Startup/Program.cs b/src/Startup/Program.cs index 3f2a63d75..11825454d 100644 --- a/src/Startup/Program.cs +++ b/src/Startup/Program.cs @@ -4,9 +4,11 @@ namespace MUnique.OpenMU.Startup; +using System; using System.ComponentModel.Design; using System.Diagnostics; using System.IO; +using System.Text.Json.Serialization; using System.Threading; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; @@ -266,6 +268,18 @@ private async Task CreateHostAsync(string[] args) .AddSingleton() .AddSingleton() .AddSingleton>(this.PlugInConfigurationsFactory) + .AddTransient(provider => + { + var persistenceContextProvider = provider.GetService(); + var dataSource = new GameConfigurationDataSource( + provider.GetService>()!, + persistenceContextProvider!); + var configId = persistenceContextProvider!.CreateNewConfigurationContext().GetDefaultGameConfigurationIdAsync(default).AsTask().WaitAndUnwrapException(); + dataSource.GetOwnerAsync(configId!.Value).AsTask().WaitAndUnwrapException(); + var referenceHandler = new ByDataSourceReferenceHandler(dataSource); + return referenceHandler; + }) + .AddTransient, GameConfigurationDataSource>() .AddHostedService() .AddHostedService() .AddHostedService(provider => provider.GetService()!) @@ -310,8 +324,11 @@ private ICollection PlugInConfigurationsFactory(IServicePro var configs = context.GetAsync().AsTask().WaitAndUnwrapException().ToList(); + var referenceHandler = new ByDataSourceReferenceHandler( + new GameConfigurationDataSource(serviceProvider.GetService>()!, persistenceContextProvider)); + // We check if we miss any plugin configurations in the database. If we do, we try to add them. - var pluginManager = new PlugInManager(null, serviceProvider.GetService()!, serviceProvider); + var pluginManager = new PlugInManager(null, serviceProvider.GetService()!, serviceProvider, referenceHandler); pluginManager.DiscoverAndRegisterPlugIns(); var typesWithCustomConfig = pluginManager.KnownPlugInTypes.Where(t => t.GetInterfaces().Contains(typeof(ISupportDefaultCustomConfiguration))).ToDictionary(t => t.GUID, t => t); @@ -319,7 +336,7 @@ private ICollection PlugInConfigurationsFactory(IServicePro var typesWithMissingCustomConfigs = configs.Where(c => string.IsNullOrWhiteSpace(c.CustomConfiguration) && typesWithCustomConfig.ContainsKey(c.TypeId)).ToList(); if (typesWithMissingCustomConfigs.Any()) { - typesWithMissingCustomConfigs.ForEach(c => this.CreateDefaultPlugInConfiguration(typesWithCustomConfig[c.TypeId]!, c)); + typesWithMissingCustomConfigs.ForEach(c => this.CreateDefaultPlugInConfiguration(typesWithCustomConfig[c.TypeId]!, c, referenceHandler)); context.SaveChanges(); } @@ -329,11 +346,11 @@ private ICollection PlugInConfigurationsFactory(IServicePro return configs; } - configs.AddRange(this.CreateMissingPlugInConfigurations(typesWithMissingConfigs, persistenceContextProvider)); + configs.AddRange(this.CreateMissingPlugInConfigurations(typesWithMissingConfigs, persistenceContextProvider, referenceHandler)); return configs; } - private IEnumerable CreateMissingPlugInConfigurations(IEnumerable plugInTypes, IPersistenceContextProvider persistenceContextProvider) + private IEnumerable CreateMissingPlugInConfigurations(IEnumerable plugInTypes, IPersistenceContextProvider persistenceContextProvider, ReferenceHandler referenceHandler) { GameConfiguration gameConfiguration; @@ -352,7 +369,7 @@ private IEnumerable CreateMissingPlugInConfigurations(IEnum gameConfiguration.PlugInConfigurations.Add(plugInConfiguration); if (plugInType.GetInterfaces().Contains(typeof(ISupportDefaultCustomConfiguration))) { - this.CreateDefaultPlugInConfiguration(plugInType, plugInConfiguration); + this.CreateDefaultPlugInConfiguration(plugInType, plugInConfiguration, referenceHandler); } yield return plugInConfiguration; @@ -361,13 +378,13 @@ private IEnumerable CreateMissingPlugInConfigurations(IEnum saveContext.SaveChanges(); } - private void CreateDefaultPlugInConfiguration(Type plugInType, PlugInConfiguration plugInConfiguration) + private void CreateDefaultPlugInConfiguration(Type plugInType, PlugInConfiguration plugInConfiguration, ReferenceHandler referenceHandler) { try { var plugin = (ISupportDefaultCustomConfiguration)Activator.CreateInstance(plugInType)!; var defaultConfig = plugin.CreateDefaultConfig(); - plugInConfiguration.SetConfiguration(defaultConfig); + plugInConfiguration.SetConfiguration(defaultConfig, referenceHandler); } catch (Exception ex) { @@ -490,7 +507,10 @@ private async Task InitializeDataAsync(string version, ILoggerFactory loggerFact serviceContainer.AddService(typeof(ILoggerFactory), loggerFactory); serviceContainer.AddService(typeof(IPersistenceContextProvider), contextProvider); - var plugInManager = new PlugInManager(null, loggerFactory, serviceContainer); + var referenceHandler = new ByDataSourceReferenceHandler( + new GameConfigurationDataSource(serviceContainer.GetService>()!, contextProvider)); + + var plugInManager = new PlugInManager(null, loggerFactory, serviceContainer, referenceHandler); plugInManager.DiscoverAndRegisterPlugInsOf(); var initialization = plugInManager.GetStrategy(version) ?? throw new Exception("Data initialization plugin not found"); await initialization.CreateInitialDataAsync(3, true).ConfigureAwait(false); diff --git a/src/Web/AdminPanel/ComponentBuilders/EmbeddedFormFieldBuilder.cs b/src/Web/AdminPanel/ComponentBuilders/EmbeddedFormFieldBuilder.cs index 9070f72f9..90ade473e 100644 --- a/src/Web/AdminPanel/ComponentBuilders/EmbeddedFormFieldBuilder.cs +++ b/src/Web/AdminPanel/ComponentBuilders/EmbeddedFormFieldBuilder.cs @@ -16,7 +16,10 @@ namespace MUnique.OpenMU.Web.AdminPanel.ComponentBuilders; public class EmbeddedFormFieldBuilder : BaseComponentBuilder, IComponentBuilder { /// - public int BuildComponent(object model, PropertyInfo propertyInfo, RenderTreeBuilder builder, int currentIndex, IChangeNotificationService notificationService) => this.BuildGenericField(model, typeof(MemberOfAggregateField<>), builder, propertyInfo, currentIndex, notificationService); + public int BuildComponent(object model, PropertyInfo propertyInfo, RenderTreeBuilder builder, int currentIndex, IChangeNotificationService notificationService) + { + return this.BuildGenericField(model, typeof(MemberOfAggregateField<>), builder, propertyInfo, currentIndex, notificationService); + } /// public bool CanBuildComponent(PropertyInfo propertyInfo) => diff --git a/src/Web/AdminPanel/Components/Form/MemberOfAggregateField.razor b/src/Web/AdminPanel/Components/Form/MemberOfAggregateField.razor index cba84bb91..9c0dd54c4 100644 --- a/src/Web/AdminPanel/Components/Form/MemberOfAggregateField.razor +++ b/src/Web/AdminPanel/Components/Form/MemberOfAggregateField.razor @@ -9,7 +9,7 @@
- @if (this.Value is null) + @if (this.CurrentValue is null) { } @@ -46,6 +46,6 @@ private void OnCreateClick() { - this.Value = this.PersistentContext.CreateNew(); + this.CurrentValue = this.PersistentContext.CreateNew(); } } diff --git a/src/Web/AdminPanel/Services/PersistentObjectsLookupController.cs b/src/Web/AdminPanel/Services/PersistentObjectsLookupController.cs index 89e24016c..17995c4aa 100644 --- a/src/Web/AdminPanel/Services/PersistentObjectsLookupController.cs +++ b/src/Web/AdminPanel/Services/PersistentObjectsLookupController.cs @@ -47,6 +47,7 @@ public async Task> GetSuggestionsAsync(string? text, IContext? return Enumerable.Empty(); } + var owner = await this._gameConfigurationSource.GetOwnerAsync(); IEnumerable values; if (this._gameConfigurationSource.IsSupporting(typeof(T))) { @@ -55,7 +56,7 @@ public async Task> GetSuggestionsAsync(string? text, IContext? else { using var context = persistenceContext is null - ? this._contextProvider.CreateNewContext(await this._gameConfigurationSource.GetOwnerAsync(Guid.Empty)) + ? this._contextProvider.CreateNewContext(owner) : null; var effectiveContext = persistenceContext ?? context; if (effectiveContext is null) diff --git a/src/Web/AdminPanel/Services/PlugInController.cs b/src/Web/AdminPanel/Services/PlugInController.cs index 8999ca9da..6d63207d0 100644 --- a/src/Web/AdminPanel/Services/PlugInController.cs +++ b/src/Web/AdminPanel/Services/PlugInController.cs @@ -7,10 +7,10 @@ namespace MUnique.OpenMU.Web.AdminPanel.Services; using System.Reflection; using Blazored.Modal; using Blazored.Modal.Services; -using MUnique.OpenMU.Web.AdminPanel.Components.Form; using MUnique.OpenMU.DataModel.Configuration; using MUnique.OpenMU.Persistence; using MUnique.OpenMU.PlugIns; +using MUnique.OpenMU.Web.AdminPanel.Components.Form; using MUnique.OpenMU.Web.AdminPanel.Models; /// @@ -173,10 +173,13 @@ public async Task ShowPlugInConfigAsync(PlugInConfigurationViewItem item) throw new ArgumentException($"{nameof(item.ConfigurationType)} must not be null.", nameof(item)); } - var configuration = item.Configuration.GetConfiguration(item.ConfigurationType) + var referenceResolver = new ByDataSourceReferenceHandler(this._dataSource); + + var configuration = item.Configuration.GetConfiguration(item.ConfigurationType, referenceResolver) ?? Activator.CreateInstance(item.ConfigurationType); var parameters = new ModalParameters(); parameters.Add(nameof(ModalCreateNew.Item), configuration!); + parameters.Add(nameof(ModalCreateNew.PersistenceContext), await this._dataSource.GetContextAsync()); var options = new ModalOptions { DisableBackgroundCancel = true, @@ -187,10 +190,11 @@ public async Task ShowPlugInConfigAsync(PlugInConfigurationViewItem item) item.PlugInName ?? string.Empty, parameters, options); + var result = await modal.Result.ConfigureAwait(false); if (!result.Cancelled) { - item.Configuration.SetConfiguration(configuration!); + item.Configuration.SetConfiguration(configuration!, referenceResolver); await (await this._dataSource.GetContextAsync().ConfigureAwait(false)).SaveChangesAsync().ConfigureAwait(false); this.DataChanged?.Invoke(this, EventArgs.Empty); } diff --git a/tests/MUnique.OpenMU.PlugIns.Tests/CustomPlugInContainerTest.cs b/tests/MUnique.OpenMU.PlugIns.Tests/CustomPlugInContainerTest.cs index ab44160f7..029fb4850 100644 --- a/tests/MUnique.OpenMU.PlugIns.Tests/CustomPlugInContainerTest.cs +++ b/tests/MUnique.OpenMU.PlugIns.Tests/CustomPlugInContainerTest.cs @@ -20,7 +20,7 @@ public class CustomPlugInContainerTest [Test] public void CreatingContainerWithNonMarkedTypeThrowsException() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); var mock = new Mock>(manager); var exception = Assert.Throws(() => { @@ -36,7 +36,7 @@ public void CreatingContainerWithNonMarkedTypeThrowsException() [Test] public void GetPlugInFromCustomContainerWithRegisteredPlugInAfterRegistration() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); var container = new CustomTestPlugInContainer(manager); manager.RegisterPlugIn(); @@ -50,7 +50,7 @@ public void GetPlugInFromCustomContainerWithRegisteredPlugInAfterRegistration() [Test] public void GetPlugInFromCustomContainerWithInitiallyRegisteredPlugIn() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); var container = new CustomTestPlugInContainer(manager); var plugIn = container.GetPlugIn(); @@ -63,7 +63,7 @@ public void GetPlugInFromCustomContainerWithInitiallyRegisteredPlugIn() [Test] public void DontGetPlugInFromCustomContainerAfterDeactivation() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); var container = new CustomTestPlugInContainer(manager); manager.DeactivatePlugIn(); @@ -77,7 +77,7 @@ public void DontGetPlugInFromCustomContainerAfterDeactivation() [Test] public void DontGetPlugInFromCustomContainerIfItDoesntSuit() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); var container = new CustomTestPlugInContainer(manager) { CreateNewPlugIns = false }; manager.RegisterPlugIn(); var plugIn = container.GetPlugIn(); @@ -90,7 +90,7 @@ public void DontGetPlugInFromCustomContainerIfItDoesntSuit() [Test] public void ReplacePlugInAtCustomContainer() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); var container = new CustomTestPlugInContainer(manager); manager.RegisterPlugIn(); @@ -104,7 +104,7 @@ public void ReplacePlugInAtCustomContainer() [Test] public void ReactivatePlugInAtCustomContainer() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); var container = new CustomTestPlugInContainer(manager); manager.RegisterPlugIn(); @@ -119,7 +119,7 @@ public void ReactivatePlugInAtCustomContainer() [Test] public void GetPlugInFromCustomContainerWithAllImplementedInterfaces() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); var container = new CustomTestPlugInContainer(manager); container.AddPlugIn(new TestCustomPlugIn2(), true); Assert.That(container.GetPlugIn(), Is.Not.Null); diff --git a/tests/MUnique.OpenMU.PlugIns.Tests/PlugInManagerTest.cs b/tests/MUnique.OpenMU.PlugIns.Tests/PlugInManagerTest.cs index 68242b459..f736586aa 100644 --- a/tests/MUnique.OpenMU.PlugIns.Tests/PlugInManagerTest.cs +++ b/tests/MUnique.OpenMU.PlugIns.Tests/PlugInManagerTest.cs @@ -21,7 +21,7 @@ public class PlugInManagerTest [Test] public void RegisteringPlugInCreatesProxy() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.RegisterPlugIn(); var point = manager.GetPlugInPoint(); @@ -35,7 +35,7 @@ public void RegisteringPlugInCreatesProxy() [Test] public async ValueTask RegisteredPlugInsActiveByDefaultAsync() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var plugIn = new ExamplePlugIn(); manager.RegisterPlugInAtPlugInPoint(plugIn); @@ -54,7 +54,7 @@ public async ValueTask RegisteredPlugInsActiveByDefaultAsync() [Test] public async ValueTask DeactivatingPlugInsAsync() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var plugIn = new ExamplePlugIn(); manager.RegisterPlugInAtPlugInPoint(plugIn); manager.DeactivatePlugIn(); @@ -74,7 +74,7 @@ public async ValueTask DeactivatingPlugInsAsync() [Test] public async ValueTask DeactivatingDeactivatedPlugInAsync() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var plugIn = new ExamplePlugIn(); manager.RegisterPlugInAtPlugInPoint(plugIn); manager.DeactivatePlugIn(); @@ -95,7 +95,7 @@ public async ValueTask DeactivatingDeactivatedPlugInAsync() [Test] public async ValueTask ActivatingActivatedPlugInAsync() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var plugIn = new ExamplePlugIn(); manager.RegisterPlugInAtPlugInPoint(plugIn); manager.ActivatePlugIn(); @@ -116,7 +116,7 @@ public async ValueTask ActivatingActivatedPlugInAsync() [Test] public async ValueTask DeactivatingOnePlugInDoesntAffectOthersAsync() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var plugIn = new ExamplePlugIn(); manager.RegisterPlugInAtPlugInPoint(plugIn); manager.RegisterPlugIn(); @@ -146,7 +146,7 @@ public async ValueTask CreatedAndActiveByConfigurationAsync(bool active) TypeId = typeof(ExamplePlugIn).GUID, IsActive = active, }; - var manager = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider(), null); var player = await TestHelper.CreatePlayerAsync().ConfigureAwait(false); var command = "test"; var args = new MyEventArgs(); @@ -191,7 +191,7 @@ public void DoStuff(Player player, string text, MyEventArgs args) } }", }; - var manager = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider(), null); var player = await TestHelper.CreatePlayerAsync().ConfigureAwait(false); var command = "test"; var args = new MyEventArgs(); @@ -213,7 +213,7 @@ public void CustomPlugInByExternalAssemblyNotFoundDoesntThrowError() IsActive = true, ExternalAssemblyName = "DoesNotExist.dll", }; - _ = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider()); + _ = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider(), null); } /// @@ -227,7 +227,7 @@ public void UnknownPlugInByConfigurationDoesntThrowError() TypeId = new Guid("A9BDA3E2-4EB6-45C3-B234-37C1819C0CB6"), IsActive = true, }; - _ = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider()); + _ = new PlugInManager(new List { configuration }, new NullLoggerFactory(), this.CreateServiceProvider(), null); } /// @@ -236,7 +236,7 @@ public void UnknownPlugInByConfigurationDoesntThrowError() [Test] public void ActivatingUnknownPlugInDoesNotThrowError() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.ActivatePlugIn(new Guid("4C38A813-F9BF-428A-8EA1-A6C90A87E583")); } @@ -246,7 +246,7 @@ public void ActivatingUnknownPlugInDoesNotThrowError() [Test] public void DeactivatingUnknownPlugInDoesNotThrowError() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.ActivatePlugIn(new Guid("4C38A813-F9BF-428A-8EA1-A6C90A87E583")); } @@ -256,7 +256,7 @@ public void DeactivatingUnknownPlugInDoesNotThrowError() [Test] public async ValueTask ActivatingPlugInsAsync() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var plugIn = new ExamplePlugIn(); manager.RegisterPlugInAtPlugInPoint(plugIn); manager.DeactivatePlugIn(); @@ -277,7 +277,7 @@ public async ValueTask ActivatingPlugInsAsync() [Test] public void AutoDiscovery() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.DiscoverAndRegisterPlugIns(); var examplePlugInPoint = manager.GetPlugInPoint(); Assert.That(examplePlugInPoint, Is.InstanceOf()); @@ -289,7 +289,7 @@ public void AutoDiscovery() [Test] public void RegisteringPlugInWithoutGuidThrowsError() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); Assert.Throws(() => manager.RegisterPlugIn()); } @@ -299,7 +299,7 @@ public void RegisteringPlugInWithoutGuidThrowsError() [Test] public void StrategyProviderCreatedForRegisteredStrategyPlugIn() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.RegisterPlugIn(); var strategyProvider = manager.GetStrategyProvider(); @@ -312,7 +312,7 @@ public void StrategyProviderCreatedForRegisteredStrategyPlugIn() [Test] public void StrategyProviderNotCreatedWithoutRegisteredStrategyPlugIn() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); var strategyProvider = manager.GetStrategyProvider(); Assert.That(strategyProvider, Is.Null); @@ -324,7 +324,7 @@ public void StrategyProviderNotCreatedWithoutRegisteredStrategyPlugIn() [Test] public void RegisteredStrategyPlugInAvailable() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.RegisterPlugIn(); var strategy = manager.GetStrategy(ExampleStrategyPlugIn.CommandKey); @@ -338,7 +338,7 @@ public void RegisteredStrategyPlugInAvailable() [Test] public void DeactivatedStrategyPlugInNotAvailable() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.RegisterPlugIn(); manager.DeactivatePlugIn(); var strategy = manager.GetStrategy(ExampleStrategyPlugIn.CommandKey); @@ -351,7 +351,7 @@ public void DeactivatedStrategyPlugInNotAvailable() [Test] public void RegisteringRegisteredStrategyPlugInDoesntThrowError() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); } @@ -362,7 +362,7 @@ public void RegisteringRegisteredStrategyPlugInDoesntThrowError() [Test] public void NoPlugInPointForStrategyPlugIn() { - var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider()); + var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider(), null); manager.RegisterPlugIn(); Assert.That(manager.GetPlugInPoint(), Is.Null); } diff --git a/tests/MUnique.OpenMU.PlugIns.Tests/PlugInProxyTypeGeneratorTest.cs b/tests/MUnique.OpenMU.PlugIns.Tests/PlugInProxyTypeGeneratorTest.cs index 4783ef116..6f2515d5f 100644 --- a/tests/MUnique.OpenMU.PlugIns.Tests/PlugInProxyTypeGeneratorTest.cs +++ b/tests/MUnique.OpenMU.PlugIns.Tests/PlugInProxyTypeGeneratorTest.cs @@ -48,7 +48,7 @@ internal interface IUnsupportedPlugIn public void ProxyIsCreated() { var generator = new PlugInProxyTypeGenerator(); - var proxy = generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null)); + var proxy = generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null, null)); Assert.That(proxy, Is.Not.Null); } @@ -60,7 +60,7 @@ public void ProxyIsCreated() public async ValueTask MultiplePlugInsAreExecutedAsync() { var generator = new PlugInProxyTypeGenerator(); - var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null)); + var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null, null)); var player = await TestHelper.CreatePlayerAsync().ConfigureAwait(false); var command = "test"; @@ -86,7 +86,7 @@ public async ValueTask MultiplePlugInsAreExecutedAsync() public async ValueTask MultipleAsyncPlugInsAreExecutedAsync() { var generator = new PlugInProxyTypeGenerator(); - var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null)); + var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null, null)); // Forcing to load NitoEx _ = new AsyncReaderWriterLock(); @@ -113,7 +113,7 @@ public async ValueTask MultipleAsyncPlugInsAreExecutedAsync() public async ValueTask InactivePlugInsAreNotExecutedAsync() { var generator = new PlugInProxyTypeGenerator(); - var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null)); + var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null, null)); var player = await TestHelper.CreatePlayerAsync().ConfigureAwait(false); var command = "test"; @@ -140,7 +140,7 @@ public async ValueTask InactivePlugInsAreNotExecutedAsync() public async ValueTask CancelEventArgsAreRespectedAsync() { var generator = new PlugInProxyTypeGenerator(); - var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null)); + var proxy = generator.GenerateProxy(new PlugInManager(null, NullLoggerFactory.Instance, null, null)); var player = await TestHelper.CreatePlayerAsync().ConfigureAwait(false); var command = "test"; @@ -165,7 +165,7 @@ public async ValueTask CancelEventArgsAreRespectedAsync() public void ErrorForClasses() { var generator = new PlugInProxyTypeGenerator(); - Assert.Throws(() => generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null))); + Assert.Throws(() => generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null, null))); } /// @@ -175,7 +175,7 @@ public void ErrorForClasses() public void ErrorForInterfaceWithoutAttribute() { var generator = new PlugInProxyTypeGenerator(); - Assert.Throws(() => generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null))); + Assert.Throws(() => generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null, null))); } /// @@ -185,6 +185,6 @@ public void ErrorForInterfaceWithoutAttribute() public void ErrorForInterfaceWithUnsupportedMethodSignature() { var generator = new PlugInProxyTypeGenerator(); - Assert.Throws(() => generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null))); + Assert.Throws(() => generator.GenerateProxy(new PlugInManager(null, new NullLoggerFactory(), null, null))); } } \ No newline at end of file diff --git a/tests/MUnique.OpenMU.Tests/GuildActionTest.cs b/tests/MUnique.OpenMU.Tests/GuildActionTest.cs index efcc767b6..40a4a78ba 100644 --- a/tests/MUnique.OpenMU.Tests/GuildActionTest.cs +++ b/tests/MUnique.OpenMU.Tests/GuildActionTest.cs @@ -164,7 +164,7 @@ private IGameServerContext CreateGameServer() new InMemoryPersistenceContextProvider(), mapInitializer, new NullLoggerFactory(), - new PlugInManager(new List(), new NullLoggerFactory(), null), + new PlugInManager(new List(), new NullLoggerFactory(), null, null), NullDropGenerator.Instance, new ConfigurationChangeMediator()); mapInitializer.PlugInManager = gameServer.PlugInManager; diff --git a/tests/MUnique.OpenMU.Tests/PacketHandlerPlugInContainerTest.cs b/tests/MUnique.OpenMU.Tests/PacketHandlerPlugInContainerTest.cs index 543817bb7..5afdc919f 100644 --- a/tests/MUnique.OpenMU.Tests/PacketHandlerPlugInContainerTest.cs +++ b/tests/MUnique.OpenMU.Tests/PacketHandlerPlugInContainerTest.cs @@ -30,7 +30,7 @@ public class PacketHandlerPlugInContainerTest [Test] public void SelectPlugInOfCorrectVersionWhenExactVersionIsAvailable() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); manager.RegisterPlugIn(); @@ -48,7 +48,7 @@ public void SelectPlugInOfCorrectVersionWhenExactVersionIsAvailable() [Test] public void SelectPlugInOfCorrectVersionWhenLowerVersionsAreAvailable() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); var clientVersionProvider = new Mock(); @@ -65,7 +65,7 @@ public void SelectPlugInOfCorrectVersionWhenLowerVersionsAreAvailable() [Test] public void SelectPlugInOfCorrectLanguage() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); var clientVersionProvider = new Mock(); @@ -82,7 +82,7 @@ public void SelectPlugInOfCorrectLanguage() [Test] public void SelectInvariantPlugIn() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); var clientVersionProvider = new Mock(); clientVersionProvider.Setup(p => p.ClientVersion).Returns(Season6E3English); @@ -98,7 +98,7 @@ public void SelectInvariantPlugIn() [Test] public void SelectPlugInAfterDeactivation() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); var clientVersionProvider = new Mock(); @@ -118,7 +118,7 @@ public void SelectPlugInAfterDeactivation() [Test] public void SelectLanguageSpecificOverInvariant() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); manager.RegisterPlugIn(); diff --git a/tests/MUnique.OpenMU.Tests/PartyTest.cs b/tests/MUnique.OpenMU.Tests/PartyTest.cs index b52cdc614..176d5ce2c 100644 --- a/tests/MUnique.OpenMU.Tests/PartyTest.cs +++ b/tests/MUnique.OpenMU.Tests/PartyTest.cs @@ -204,7 +204,7 @@ private IGameContext GetGameContext() gameConfig.Maps.Add(contextProvider.CreateNewContext().CreateNew()); var mapInitializer = new MapInitializer(gameConfig, new NullLogger(), NullDropGenerator.Instance, null); - var gameContext = new GameContext(gameConfig, contextProvider, mapInitializer, new NullLoggerFactory(), new PlugInManager(new List(), new NullLoggerFactory(), null), NullDropGenerator.Instance, new ConfigurationChangeMediator()); + var gameContext = new GameContext(gameConfig, contextProvider, mapInitializer, new NullLoggerFactory(), new PlugInManager(new List(), new NullLoggerFactory(), null, null), NullDropGenerator.Instance, new ConfigurationChangeMediator()); gameContext.Configuration.MaximumPartySize = 5; mapInitializer.PlugInManager = gameContext.PlugInManager; mapInitializer.PathFinderPool = gameContext.PathFinderPool; diff --git a/tests/MUnique.OpenMU.Tests/TestHelper.cs b/tests/MUnique.OpenMU.Tests/TestHelper.cs index 50b3ff415..b235eeccf 100644 --- a/tests/MUnique.OpenMU.Tests/TestHelper.cs +++ b/tests/MUnique.OpenMU.Tests/TestHelper.cs @@ -43,7 +43,7 @@ public static async ValueTask CreatePlayerAsync() gameConfig.Object.Maps.Add(map.Object); var mapInitializer = new MapInitializer(gameConfig.Object, new NullLogger(), NullDropGenerator.Instance, null); - var gameContext = new GameContext(gameConfig.Object, new InMemoryPersistenceContextProvider(), mapInitializer, new NullLoggerFactory(), new PlugInManager(null, new NullLoggerFactory(), null), NullDropGenerator.Instance, new ConfigurationChangeMediator()); + var gameContext = new GameContext(gameConfig.Object, new InMemoryPersistenceContextProvider(), mapInitializer, new NullLoggerFactory(), new PlugInManager(null, new NullLoggerFactory(), null, null), NullDropGenerator.Instance, new ConfigurationChangeMediator()); mapInitializer.PlugInManager = gameContext.PlugInManager; mapInitializer.PathFinderPool = gameContext.PathFinderPool; return await CreatePlayerAsync(gameContext).ConfigureAwait(false); diff --git a/tests/MUnique.OpenMU.Tests/TradeTest.cs b/tests/MUnique.OpenMU.Tests/TradeTest.cs index c6b361ba3..e5b38804d 100644 --- a/tests/MUnique.OpenMU.Tests/TradeTest.cs +++ b/tests/MUnique.OpenMU.Tests/TradeTest.cs @@ -90,7 +90,7 @@ public async ValueTask TradeFinishTestAsync() trader2.TradingPartner = trader1; var gameContext = new Mock(); - gameContext.Setup(c => c.PlugInManager).Returns(new PlugInManager(null, new NullLoggerFactory(), null)); + gameContext.Setup(c => c.PlugInManager).Returns(new PlugInManager(null, new NullLoggerFactory(), null, null)); gameContext.Setup(c => c.PersistenceContextProvider).Returns(new InMemoryPersistenceContextProvider()); Mock.Get(trader1).Setup(m => m.GameContext).Returns(gameContext.Object); diff --git a/tests/MUnique.OpenMU.Tests/ViewPlugInContainerTest.cs b/tests/MUnique.OpenMU.Tests/ViewPlugInContainerTest.cs index e2d84f25a..dfd3666b2 100644 --- a/tests/MUnique.OpenMU.Tests/ViewPlugInContainerTest.cs +++ b/tests/MUnique.OpenMU.Tests/ViewPlugInContainerTest.cs @@ -40,7 +40,7 @@ public interface ISomeViewPlugIn : IViewPlugIn [Test] public void SelectPlugInOfCorrectVersionWhenExactVersionIsAvailable() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); manager.RegisterPlugIn(); @@ -54,7 +54,7 @@ public void SelectPlugInOfCorrectVersionWhenExactVersionIsAvailable() [Test] public void SelectPlugInOfCorrectVersionWhenLowerVersionsAreAvailable() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); manager.RegisterPlugIn(); @@ -68,7 +68,7 @@ public void SelectPlugInOfCorrectVersionWhenLowerVersionsAreAvailable() [Test] public void SelectPlugInOfCorrectLanguage() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); var containerForSeason6English = new ViewPlugInContainer(this.CreatePlayer(manager), Season6E3English, manager); @@ -81,7 +81,7 @@ public void SelectPlugInOfCorrectLanguage() [Test] public void SelectInvariantPlugIn() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); var containerForSeason6English = new ViewPlugInContainer(this.CreatePlayer(manager), Season6E3English, manager); Assert.That(containerForSeason6English.GetPlugIn()!.GetType(), Is.EqualTo(typeof(InvariantSeasonPlugIn))); @@ -93,7 +93,7 @@ public void SelectInvariantPlugIn() [Test] public void SelectPlugInAfterDeactivation() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); manager.RegisterPlugIn(); @@ -109,7 +109,7 @@ public void SelectPlugInAfterDeactivation() [Test] public void SelectLanguageSpecificOverInvariant() { - var manager = new PlugInManager(null, new NullLoggerFactory(), null); + var manager = new PlugInManager(null, new NullLoggerFactory(), null, null); manager.RegisterPlugIn(); manager.RegisterPlugIn(); var containerForSeason9 = new ViewPlugInContainer(this.CreatePlayer(manager), Season9E2English, manager);