Skip to content

Commit 02d8e16

Browse files
committed
args still not working
1 parent 87f760e commit 02d8e16

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

CustomCommands/Interfaces/IPluginUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IPluginUtilities
1818
/// </summary>
1919
/// <param name="input"></param>
2020
/// <returns></returns>
21-
string[] AddCSSTagsToAliases(string[] input);
21+
string[] AddCSSTagsToAliases(List<string> input);
2222

2323
/// <summary>
2424
/// Splits a string by comma, semicolon, or whitespace characters.

CustomCommands/Services/PluginUtilities.cs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,63 @@ public PluginUtilities(IPluginGlobals PluginGlobals, IReplaceTagsFunctions Repla
2626
public string[] GettingCommandsFromString(string commands)
2727
{
2828
string[] splitCommands = SplitStringByCommaOrSemicolon(commands);
29+
List<string> commandsList = new List<string>();
30+
// Removes arguments from the command when spaces are present
31+
for (int i = 0; i < splitCommands.Length; i++)
32+
{
33+
if (splitCommands[i].Contains(' '))
34+
{
35+
Logger.LogInformation($"Contains space!");
36+
if (splitCommands[i].IndexOf(' ') == 0)
37+
{
38+
commandsList.Add(splitCommands[i]);
39+
continue;
40+
}
41+
Logger.LogInformation($"Is multiple args");
42+
string sub = splitCommands[i].Substring(0, splitCommands[i].IndexOf(' '));
43+
Logger.LogInformation($"Sub: {sub}");
44+
if (commandsList.Contains(sub))
45+
{
46+
Logger.LogInformation("In IF");
47+
continue;
48+
}
49+
50+
if (!contains)
51+
commandsList.Add(sub);
52+
}
53+
else
54+
{
55+
if (!commandsList.Contains(splitCommands[i]))
56+
commandsList.Add(splitCommands[i]);
57+
}
58+
}
59+
60+
61+
foreach (var command in commandsList)
62+
{
63+
Logger.LogInformation($"Command: {command}");
64+
}
2965

3066
if (PluginGlobals.Config.RegisterCommandsAsCSSFramework)
31-
return AddCSSTagsToAliases(splitCommands);
67+
return AddCSSTagsToAliases(commandsList);
3268

33-
return splitCommands;
69+
70+
return commandsList.ToArray();
3471
}
3572

36-
public string[] AddCSSTagsToAliases(string[] input)
73+
public string[] AddCSSTagsToAliases(List<string> input)
3774
{
38-
for (int i = 0; i < input.Length; i++)
75+
for (int i = 0; i < input.Count; i++)
3976
{
4077
if (!input[i].StartsWith("css_"))
4178
input[i] = "css_" + input[i];
4279
}
43-
return input;
80+
return input.ToArray();
4481
}
4582

4683
public string[] SplitStringByCommaOrSemicolon(string str)
4784
{
48-
return Regex.Split(str, ",|;|\\s")
85+
return Regex.Split(str, "[,;]")
4986
.Where(s => !string.IsNullOrEmpty(s))
5087
.ToArray();
5188
}

CustomCommands/Services/RegisterCommands.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ public void AddCommands(Commands cmd)
3939
for (int i = 0; i < aliases.Length; i++)
4040
{
4141
string alias = aliases[i];
42+
// System.Console.WriteLine($"Pre Command: {alias}.");
4243
plugin.AddCommand(alias, cmd.Description,
4344
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
4445
(player, info) =>
4546
{
4647
if (player == null)
4748
return;
49+
System.Console.WriteLine($"Post Command: {alias}.");
4850

4951
if (info.ArgCount < alias.Split(' ').Length)
5052
{

0 commit comments

Comments
 (0)