Skip to content

Commit 383342e

Browse files
authored
Merge pull request #33 from HerrMagiic/feature/commandargs
Feature/commandargs
2 parents 98c04a3 + 594895e commit 383342e

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

CustomCommands/CustomCommands.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using CounterStrikeSharp.API.Core;
22
using CounterStrikeSharp.API.Core.Attributes;
33
using CustomCommands.Interfaces;
4-
using CustomCommands.Services;
54
using Microsoft.Extensions.Logging;
65

76
namespace CustomCommands;
@@ -10,7 +9,7 @@ namespace CustomCommands;
109
public partial class CustomCommands : BasePlugin, IPluginConfig<CustomCommandsConfig>
1110
{
1211
public override string ModuleName => "CustomCommands";
13-
public override string ModuleVersion => "1.0.9";
12+
public override string ModuleVersion => "1.1.0";
1413
public override string ModuleAuthor => "HerrMagic";
1514
public override string ModuleDescription => "Create your own commands per config";
1615

@@ -60,6 +59,8 @@ public override void Load(bool hotReload)
6059

6160
if (comms != null)
6261
{
62+
PluginGlobals.CustomCommands = comms;
63+
6364
comms = RegisterCommands.CheckForDuplicateCommands(comms);
6465
// Add commands from the JSON file to the server
6566
foreach (var com in comms)

CustomCommands/Interfaces/IPluginGlobals.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ public interface IPluginGlobals
88
CenterServerElement centerServerOn { get; set; }
99
CustomCommandsConfig Config { get; set; }
1010
List<CooldownTimer> CooldownTimer { get; set; }
11+
List<Commands> CustomCommands { get; set; }
1112
}

CustomCommands/Services/PluginGlobals.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ public class PluginGlobals : IPluginGlobals
88
public CenterServerElement centerServerOn { get; set; } = new();
99
public CustomCommandsConfig Config { get; set; } = new();
1010
public List<CooldownTimer> CooldownTimer { get; set; } = new();
11+
public List<Commands> CustomCommands { get; set; } = new();
1112
}

CustomCommands/Services/RegisterCommands.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,23 @@ public void AddCommands(Commands com)
3737
{
3838
if (player == null) return;
3939

40-
if (com.Permission.PermissionList.Count > 0 && com.Permission != null)
41-
if (!PluginUtilities.RequiresPermissions(player, com.Permission))
40+
var command = com;
41+
if (info.ArgCount > 0)
42+
{
43+
command = PluginGlobals.CustomCommands.Find(x => x.Command.Contains(aliases[i])) ?? com;
44+
}
45+
46+
if (command.Permission.PermissionList.Count > 0 && command.Permission != null)
47+
if (!PluginUtilities.RequiresPermissions(player, command.Permission))
4248
return;
4349

44-
if(CooldownManager.IsCommandOnCooldown(player, com)) return;
50+
if(CooldownManager.IsCommandOnCooldown(player, command)) return;
4551

46-
CooldownManager.SetCooldown(player, com);
52+
CooldownManager.SetCooldown(player, command);
4753

48-
MessageManager.SendMessage(player, com);
54+
MessageManager.SendMessage(player, command);
4955

50-
PluginUtilities.ExecuteServerCommands(com, player);
56+
PluginUtilities.ExecuteServerCommands(command, player);
5157
});
5258
}
5359
}

CustomCommands/test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
* [ ] check if the string pattern check works
66
* [ ] check cooldown funktion for normal int and than object
77
* [ ] check if padleft color tag works now
8+
* [ ] check if command args works

0 commit comments

Comments
 (0)