Skip to content

Commit 96e0b9a

Browse files
committed
fixed WrappedLine accepting normal Array
1 parent b337fa2 commit 96e0b9a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CustomCommands/Services/RegisterCommands.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ public void AddCommands(Commands cmd)
3838

3939
for (int i = 0; i < aliases.Length; i++)
4040
{
41-
plugin.AddCommand(aliases[i], cmd.Description,
41+
string alias = aliases[i];
42+
plugin.AddCommand(alias, cmd.Description,
4243
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
4344
(player, info) =>
4445
{
4546
if (player == null)
4647
return;
47-
if (info.ArgCount < aliases[i].Split(' ').Length)
48+
49+
if (info.ArgCount < alias.Split(' ').Length)
4850
{
49-
player.PrintToChat($"This command requires at least {aliases[i].Split(' ').Length-1} arguments.");
51+
player.PrintToChat($"This command requires at least {alias.Split(' ').Length-1} arguments.");
5052
return;
5153
}
5254

@@ -55,7 +57,7 @@ public void AddCommands(Commands cmd)
5557
// Check if the command has arguments and if it does, check if the command really exists in the list
5658
if (info.ArgCount > 1)
5759
{
58-
var findcommand = PluginGlobals.CustomCommands.Find(x => x.Command.Contains(aliases[i] + $" {info.ArgString}"));
60+
var findcommand = PluginGlobals.CustomCommands.Find(x => x.Command.Contains(alias + $" {info.ArgString}"));
5961
// Check if the command is equal to the found command
6062
if (findcommand! != command)
6163
return;

CustomCommands/Services/ReplaceTagsFunction.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public string[] ReplaceTags(dynamic input, CCSPlayerController player)
3737
List<string> output = WrappedLine(input);
3838

3939
for (int i = 0; i < output.Count; i++)
40-
output[i] = ReplaceLanguageTags(input[i]);
40+
output[i] = ReplaceLanguageTags(output[i]);
4141

4242
output = WrappedLine(output.ToArray());
4343

@@ -184,6 +184,13 @@ public List<string> WrappedLine(dynamic input)
184184
Logger.LogError($"{PluginGlobals.Config.LogPrefix} Message is not a string or array");
185185
break;
186186
}
187+
} else if (input is Array inputArray)
188+
{
189+
foreach (string arrayElement in inputArray)
190+
{
191+
string[] lines = arrayElement.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None) ?? Array.Empty<string>();
192+
output.AddRange(lines);
193+
}
187194
}
188195
else
189196
{

0 commit comments

Comments
 (0)