@@ -15,15 +15,13 @@ public class ReplaceTagsFunctions : IReplaceTagsFunctions
1515 private readonly IPluginGlobals PluginGlobals ;
1616 private readonly PluginContext PluginContext ;
1717 private readonly ILogger < CustomCommands > Logger ;
18- private readonly IPluginUtilities PluginUtilities ;
1918
2019 public ReplaceTagsFunctions ( IPluginGlobals PluginGlobals , IPluginContext PluginContext ,
21- ILogger < CustomCommands > Logger , IPluginUtilities PluginUtilities )
20+ ILogger < CustomCommands > Logger )
2221 {
2322 this . PluginGlobals = PluginGlobals ;
2423 this . PluginContext = ( PluginContext as PluginContext ) ! ;
2524 this . Logger = Logger ;
26- this . PluginUtilities = PluginUtilities ;
2725 }
2826
2927 public string [ ] ReplaceTags ( string [ ] input , CCSPlayerController player )
@@ -96,7 +94,7 @@ public string ReplaceMessageTags(string input, CCSPlayerController player)
9694 public string ReplaceColorTags ( string input )
9795 {
9896 // PadLeft the color tag if it's not already there because the game doesn't support color tags at the start of a string.
99- input = PluginUtilities . PadLeftColorTag ( input ) ;
97+ input = PadLeftColorTag ( input ) ;
10098
10199 Dictionary < string , string > replacements = new ( )
102100 {
@@ -164,4 +162,42 @@ public string[] WrappedLine(dynamic input)
164162
165163 return output . ToArray ( ) ;
166164 }
165+
166+ /// <summary>
167+ /// Moves the color tag one space the the left if it's not already there.
168+ /// Because the game doesn't support color tags at the start of a string.
169+ /// </summary>
170+ /// <param name="input"></param>
171+ /// <returns></returns>
172+ private string PadLeftColorTag ( string input )
173+ {
174+ string [ ] colorTagList = new string [ ] {
175+ "{DEFAULT}" ,
176+ "{WHITE}" ,
177+ "{DARKRED}" ,
178+ "{RED}" ,
179+ "{LIGHTRED}" ,
180+ "{GREEN}" ,
181+ "{LIME}" ,
182+ "{OLIVE}" ,
183+ "{ORANGE}" ,
184+ "{GOLD}" ,
185+ "{YELLOW}" ,
186+ "{BLUE}" ,
187+ "{DARKBLUE}" ,
188+ "{LIGHTPURPLE}" ,
189+ "{PURPLE}" ,
190+ "{SILVER}" ,
191+ "{BLUEGREY}" ,
192+ "{GREY}" ,
193+ } ;
194+ foreach ( var colorTag in colorTagList )
195+ {
196+ if ( input . StartsWith ( colorTag ) )
197+ {
198+ return " " + input ;
199+ }
200+ }
201+ return input ;
202+ }
167203}
0 commit comments