@@ -6,12 +6,13 @@ namespace CustomCommands.Interfaces;
66
77public class CooldownManager : ICooldownManager
88{
9- public IPluginGlobals PluginGlobals { get ; }
10- public IReplaceTagsFunctions ReplaceTagsFunctions { get ; }
9+ public IPluginGlobals _pluginGlobals { get ; }
10+ public IReplaceTagsFunctions _replaceTagsFunctions { get ; }
11+
1112 public CooldownManager ( IPluginGlobals PluginGlobals , IReplaceTagsFunctions ReplaceTagsFunctions )
1213 {
13- this . PluginGlobals = PluginGlobals ;
14- this . ReplaceTagsFunctions = ReplaceTagsFunctions ;
14+ _pluginGlobals = PluginGlobals ;
15+ _replaceTagsFunctions = ReplaceTagsFunctions ;
1516 }
1617
1718 /// <summary>
@@ -42,11 +43,11 @@ public bool IsCommandOnCooldown(CCSPlayerController player, Commands cmd)
4243 /// <returns>True if the command is on cooldown, false otherwise.</returns>
4344 public bool IsCommandOnCooldownWithCondition ( Func < CooldownTimer , bool > predicate , CCSPlayerController player , Commands cmd )
4445 {
45- var index = PluginGlobals . CooldownTimer . FindIndex ( x => predicate ( x ) && x . CooldownTime > DateTime . Now ) ;
46+ var index = _pluginGlobals . CooldownTimer . FindIndex ( x => predicate ( x ) && x . CooldownTime > DateTime . Now ) ;
4647
4748 if ( index != - 1 )
4849 {
49- var totalSeconds = ( double ) PluginGlobals . CooldownTimer [ index ] . CooldownTime . Subtract ( DateTime . Now ) . TotalSeconds ;
50+ var totalSeconds = ( double ) _pluginGlobals . CooldownTimer [ index ] . CooldownTime . Subtract ( DateTime . Now ) . TotalSeconds ;
5051 var totalSecondsRounded = ( int ) Math . Round ( totalSeconds ) ;
5152 var timeleft = totalSecondsRounded . ToString ( ) ;
5253 var message = "" ;
@@ -57,14 +58,14 @@ public bool IsCommandOnCooldownWithCondition(Func<CooldownTimer, bool> predicate
5758 var cooldown = JsonSerializer . Deserialize < Cooldown > ( cmd . Cooldown . GetRawText ( ) ) ;
5859 Console . WriteLine ( cooldown . CooldownMessage ) ;
5960 string [ ] replaceTimeleft = { cooldown . CooldownMessage . Replace ( "{TIMELEFT}" , timeleft ) } ;
60- message = ReplaceTagsFunctions . ReplaceTags ( replaceTimeleft , player ) [ 0 ] ;
61+ message = _replaceTagsFunctions . ReplaceTags ( replaceTimeleft , player ) [ 0 ] ;
6162 }
6263 catch ( JsonException )
6364 {
6465 message = $ "This command is for { timeleft } seconds on cooldown";
6566 }
6667
67- player . PrintToChat ( $ "{ PluginGlobals . Config . Prefix } { message } ") ;
68+ player . PrintToChat ( $ "{ _pluginGlobals . Config . Prefix } { message } ") ;
6869
6970 return true ;
7071 }
@@ -89,25 +90,25 @@ public void AddToCooldownList(bool isGlobal, int playerID, Guid commandID, int c
8990
9091 if ( isGlobal )
9192 {
92- int index = PluginGlobals . CooldownTimer . FindIndex ( x =>
93+ int index = _pluginGlobals . CooldownTimer . FindIndex ( x =>
9394 x . IsGlobal == true
9495 && x . CommandID == commandID ) ;
9596
9697 if ( index != - 1 )
97- PluginGlobals . CooldownTimer [ index ] . CooldownTime = timer . CooldownTime ;
98+ _pluginGlobals . CooldownTimer [ index ] . CooldownTime = timer . CooldownTime ;
9899 else
99- PluginGlobals . CooldownTimer . Add ( timer ) ;
100+ _pluginGlobals . CooldownTimer . Add ( timer ) ;
100101 }
101102 else
102103 {
103104 timer . PlayerID = playerID ;
104- int index = PluginGlobals . CooldownTimer . FindIndex ( x =>
105+ int index = _pluginGlobals . CooldownTimer . FindIndex ( x =>
105106 x . PlayerID == playerID
106107 && x . CommandID == commandID ) ;
107108 if ( index != - 1 )
108- PluginGlobals . CooldownTimer [ index ] . CooldownTime = timer . CooldownTime ;
109+ _pluginGlobals . CooldownTimer [ index ] . CooldownTime = timer . CooldownTime ;
109110 else
110- PluginGlobals . CooldownTimer . Add ( timer ) ;
111+ _pluginGlobals . CooldownTimer . Add ( timer ) ;
111112 }
112113 }
113114
@@ -124,7 +125,7 @@ public void SetCooldown(CCSPlayerController player, Commands cmd)
124125 {
125126 case JsonValueKind . Number :
126127
127- int cooldown = cmd . Cooldown . GetInt32 ( ) ;
128+ var cooldown = cmd . Cooldown . GetInt32 ( ) ;
128129 if ( cooldown == 0 )
129130 break ;
130131
0 commit comments