Skip to content

Commit

Permalink
Fix recursive dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Sep 10, 2024
1 parent 2f0a2ab commit 86ec8e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/CS2/Gangs/GangServiceCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using GangsAPI.Extensions;
using GangsAPI.Services;
using GangsAPI.Services.Gang;
using GangsAPI.Services.Menu;
using GangsAPI.Services.Player;
using Microsoft.Extensions.DependencyInjection;
using Mock;
using SQLImpl;

namespace GangsImpl;
Expand All @@ -15,11 +17,15 @@ public void ConfigureServices(IServiceCollection serviceCollection) {
serviceCollection.AddScoped<IDBConfig, EnvDBConfig>();
serviceCollection.AddPluginBehavior<IGangManager, MySQLGangManager>();
serviceCollection.AddPluginBehavior<IPlayerManager, MySQLPlayerManager>();
serviceCollection
.AddPluginBehavior<IMenuManager, CommandBasedMenuManager>();
serviceCollection.AddPluginBehavior<IStatManager, MySQLStatManager>();
serviceCollection
.AddPluginBehavior<IGangStatManager, MySQLGangInstanceManager>();
serviceCollection
.AddPluginBehavior<IPlayerStatManager, MySQLPlayerInstanceManager>();
serviceCollection.AddPluginBehavior<IRankManager, MySQLRankManager>();

serviceCollection.RegisterCommands();

serviceCollection.AddPluginBehavior<PlayerJoinCreationListener>();
Expand Down
5 changes: 4 additions & 1 deletion src/GangsImpl/Mock/CommandBasedMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

namespace Mock;

public class CommandBasedMenuManager(ICommandManager cmd) : MockMenuManager {
public class CommandBasedMenuManager(Lazy<ICommandManager> cmdMgr)
: MockMenuManager {
private ICommandManager cmd => cmdMgr.Value;

public override void Start(BasePlugin? plugin, bool hotReload) {
for (var i = 0; i < 10; i++) cmd.RegisterCommand(new DigitCommand(this, i));
}
Expand Down

0 comments on commit 86ec8e4

Please sign in to comment.