33using CounterStrikeSharp . API . Core . Plugin ;
44using CustomCommands . Interfaces ;
55using CustomCommands . Model ;
6+ using Microsoft . Extensions . Logging ;
67
78namespace CustomCommands . Services ;
89public class MessageManager : IMessageManager
910{
1011 private readonly IPluginGlobals PluginGlobals ;
1112 private readonly IReplaceTagsFunctions ReplaceTagsFunctions ;
12- private readonly CustomCommands PluginContext ;
13+ private readonly PluginContext PluginContext ;
1314
1415 public MessageManager ( IPluginGlobals PluginGlobals , IReplaceTagsFunctions ReplaceTagsFunctions , IPluginContext PluginContext )
1516 {
1617 this . PluginGlobals = PluginGlobals ;
1718 this . ReplaceTagsFunctions = ReplaceTagsFunctions ;
18- this . PluginContext = ( ( PluginContext as PluginContext ) ! . Plugin as CustomCommands ) ! ;
19+ this . PluginContext = ( PluginContext as PluginContext ) ! ;
1920 }
2021
2122 public void SendMessage ( CCSPlayerController player , Commands cmd )
@@ -53,6 +54,8 @@ public void SendMessage(CCSPlayerController player, Commands cmd)
5354
5455 public void PrintToCenterClient ( CCSPlayerController player , Commands cmd )
5556 {
57+ CustomCommands plugin = ( PluginContext . Plugin as CustomCommands ) ! ;
58+
5659 string message = ReplaceTagsFunctions . ReplaceMessageTags ( cmd . CenterMessage . Message , player ) ;
5760
5861 var CenterClientElement = new CenterClientElement
@@ -61,15 +64,17 @@ public void PrintToCenterClient(CCSPlayerController player, Commands cmd)
6164 Message = message
6265 } ;
6366 PluginGlobals . centerClientOn . Add ( CenterClientElement ) ;
64- PluginContext . AddTimer ( cmd . CenterMessage . Time , ( ) => PluginGlobals . centerClientOn . Remove ( CenterClientElement ) ) ;
67+ plugin . AddTimer ( cmd . CenterMessage . Time , ( ) => PluginGlobals . centerClientOn . Remove ( CenterClientElement ) ) ;
6568 }
6669
6770 public void PrintToAllCenter ( Commands cmd )
6871 {
72+ CustomCommands plugin = ( PluginContext . Plugin as CustomCommands ) ! ;
73+
6974 PluginGlobals . centerServerOn . Message = cmd . CenterMessage . Message ;
7075 PluginGlobals . centerServerOn . IsRunning = true ;
7176
72- PluginContext . AddTimer ( cmd . CenterMessage . Time , ( ) =>
77+ plugin . AddTimer ( cmd . CenterMessage . Time , ( ) =>
7378 {
7479 PluginGlobals . centerServerOn . IsRunning = false ;
7580 } ) ;
0 commit comments