diff --git a/mod/TTT.Round/RoundBehavior.cs b/mod/TTT.Round/RoundBehavior.cs index bbc413c..360c369 100644 --- a/mod/TTT.Round/RoundBehavior.cs +++ b/mod/TTT.Round/RoundBehavior.cs @@ -5,6 +5,7 @@ using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Timers; +using Microsoft.Extensions.DependencyInjection; using TTT.Public.Behaviors; using TTT.Public.Extensions; using TTT.Public.Formatting; @@ -13,13 +14,17 @@ namespace TTT.Round; -public class RoundBehavior(IRoleService _roleService) - : IRoundService, IPluginBehavior { +public class RoundBehavior : IRoundService, IPluginBehavior { private Round? _round; private int _roundId = 1; private RoundStatus _roundStatus = RoundStatus.Paused; + private readonly IServiceProvider _provider; + private IRoleService _roleService = null!; + + public RoundBehavior(IServiceProvider provider) { _provider = provider; } public void Start(BasePlugin plugin) { + _roleService = _provider.GetRequiredService(); plugin.RegisterListener(TickWaiting); plugin.AddCommandListener("jointeam", OnTeamJoin); VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(BlockDamage, diff --git a/src/TTT/TTTServiceCollection.cs b/src/TTT/TTTServiceCollection.cs index e082150..89f25c5 100644 --- a/src/TTT/TTTServiceCollection.cs +++ b/src/TTT/TTTServiceCollection.cs @@ -11,9 +11,9 @@ namespace TTT; public class TTTServiceCollection : IPluginServiceCollection { public void ConfigureServices(IServiceCollection serviceCollection) { + serviceCollection.AddTTTRoles(); serviceCollection.AddRoundService(); serviceCollection.AddPlayerService(); - serviceCollection.AddTTTRoles(); serviceCollection.AddDetectiveBehavior(); serviceCollection.AddLogsService(); serviceCollection.AddManagerService();