Skip to content

Commit d36a596

Browse files
committed
Added tag support for server commands
1 parent 69fb2f6 commit d36a596

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CustomCommands/Interfaces/IPluginUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ namespace CustomCommands.Interfaces;
77
public interface IPluginUtilities
88
{
99
string[] SplitStringByCommaOrSemicolon(string str);
10-
void ExecuteServerCommands(Commands cmd);
10+
void ExecuteServerCommands(Commands cmd, CCSPlayerController player);
1111
bool RequiresPermissions(CCSPlayerController player, Permission permissions);
1212
}

CustomCommands/Services/PluginUtilities.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ namespace CustomCommands.Services;
1010
public class PluginUtilities : IPluginUtilities
1111
{
1212
private readonly IPluginGlobals PluginGlobals;
13+
private readonly IReplaceTagsFunctions ReplaceTagsFunctions;
1314

14-
public PluginUtilities(IPluginGlobals PluginGlobals)
15+
public PluginUtilities(IPluginGlobals PluginGlobals, IReplaceTagsFunctions ReplaceTagsFunctions)
1516
{
1617
this.PluginGlobals = PluginGlobals;
18+
this.ReplaceTagsFunctions = ReplaceTagsFunctions;
1719
}
1820

1921
public string[] SplitStringByCommaOrSemicolon(string str)
@@ -23,13 +25,13 @@ public string[] SplitStringByCommaOrSemicolon(string str)
2325
.ToArray();
2426
}
2527

26-
public void ExecuteServerCommands(Commands cmd)
28+
public void ExecuteServerCommands(Commands cmd, CCSPlayerController player)
2729
{
2830
if (cmd.ServerCommands.Count == 0) return;
2931

3032
foreach (var serverCommand in cmd.ServerCommands)
3133
{
32-
Server.ExecuteCommand(serverCommand);
34+
Server.ExecuteCommand(ReplaceTagsFunctions.ReplaceMessageTags(serverCommand, player));
3335
}
3436
}
3537
public bool RequiresPermissions(CCSPlayerController player, Permission permissions)

CustomCommands/Services/RegisterCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void AddCommands(Commands com)
4141

4242
MessageManager.SendMessage(player, com);
4343

44-
PluginUtilities.ExecuteServerCommands(com);
44+
PluginUtilities.ExecuteServerCommands(com, player);
4545
});
4646
}
4747
}

Examples/ServerCommands.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,15 @@
4040
"@customcommands/surf"
4141
]
4242
}
43+
},
44+
{
45+
"Title": "Kickme",
46+
"Description": "command that kicks yourself",
47+
"Command": "kickme",
48+
"Message": "Getting Kicket",
49+
"PrintTo": 0,
50+
"ServerCommands": [
51+
"kick {PLAYERNAME}" // Tags work for commands as well
52+
]
4353
}
4454
]

0 commit comments

Comments
 (0)