Skip to content

Commit dde7cc4

Browse files
authored
Merge pull request #36 from HerrMagiic/dev
v2.0.0
2 parents 8e37371 + 2450181 commit dde7cc4

22 files changed

+424
-92
lines changed

CustomCommands.sln

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,22 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.7.34018.315
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomCommands", "CustomCommands\CustomCommands.csproj", "{CFD687D3-02AF-4F8B-B561-ED01C4B2C5D3}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomCommands", "CustomCommands\CustomCommands.csproj", "{CFD687D3-02AF-4F8B-B561-ED01C4B2C5D3}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{DBAE0443-7660-456C-B185-444366A42766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{DBAE0443-7660-456C-B185-444366A42766}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{DBAE0443-7660-456C-B185-444366A42766}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{DBAE0443-7660-456C-B185-444366A42766}.Release|Any CPU.Build.0 = Release|Any CPU
18-
{C4B486A3-D8FC-41AC-827E-905BAFF50A9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19-
{C4B486A3-D8FC-41AC-827E-905BAFF50A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
20-
{C4B486A3-D8FC-41AC-827E-905BAFF50A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
21-
{C4B486A3-D8FC-41AC-827E-905BAFF50A9D}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{A590C358-C1B2-4F21-B9B0-FE56B6562F39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{A590C358-C1B2-4F21-B9B0-FE56B6562F39}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{A590C358-C1B2-4F21-B9B0-FE56B6562F39}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{A590C358-C1B2-4F21-B9B0-FE56B6562F39}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{8BF8B3C3-FE3F-459E-B414-72469816539A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{8BF8B3C3-FE3F-459E-B414-72469816539A}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{8BF8B3C3-FE3F-459E-B414-72469816539A}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{8BF8B3C3-FE3F-459E-B414-72469816539A}.Release|Any CPU.Build.0 = Release|Any CPU
3014
{CFD687D3-02AF-4F8B-B561-ED01C4B2C5D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3115
{CFD687D3-02AF-4F8B-B561-ED01C4B2C5D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
3216
{CFD687D3-02AF-4F8B-B561-ED01C4B2C5D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
3317
{CFD687D3-02AF-4F8B-B561-ED01C4B2C5D3}.Release|Any CPU.Build.0 = Release|Any CPU
18+
{F5F2148E-D3A3-4196-B97A-4E0941326365}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{F5F2148E-D3A3-4196-B97A-4E0941326365}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{F5F2148E-D3A3-4196-B97A-4E0941326365}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{F5F2148E-D3A3-4196-B97A-4E0941326365}.Release|Any CPU.Build.0 = Release|Any CPU
3422
EndGlobalSection
3523
GlobalSection(SolutionProperties) = preSolution
3624
HideSolutionNode = FALSE

CustomCommands/CustomCommands.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace CustomCommands;
99
public partial class CustomCommands : BasePlugin, IPluginConfig<CustomCommandsConfig>
1010
{
1111
public override string ModuleName => "CustomCommands";
12-
public override string ModuleVersion => "1.0.9";
12+
public override string ModuleVersion => "2.0.0";
1313
public override string ModuleAuthor => "HerrMagic";
1414
public override string ModuleDescription => "Create your own commands per config";
1515

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

6060
if (comms != null)
6161
{
62+
PluginGlobals.CustomCommands = comms;
63+
6264
comms = RegisterCommands.CheckForDuplicateCommands(comms);
6365
// Add commands from the JSON file to the server
6466
foreach (var com in comms)

CustomCommands/CustomCommandsServiceCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class CustomCommandsServiceCollection : IPluginServiceCollection<CustomCo
1010
public void ConfigureServices(IServiceCollection services)
1111
{
1212
services.Scan(scan => scan
13-
.FromAssemblyOf<IPermissionsManager>()
13+
.FromAssemblyOf<IRegisterCommands>()
1414
.AddClasses()
1515
.AsImplementedInterfaces()
1616
.WithSingletonLifetime()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using CounterStrikeSharp.API.Core;
2+
using CustomCommands.Model;
3+
4+
namespace CustomCommands.Interfaces;
5+
6+
public interface ICooldownManager
7+
{
8+
bool IsCommandOnCooldown(CCSPlayerController player, Commands cmd);
9+
void AddToCooldownList(bool isGlobal, int playerID, Guid commandID, int cooldownTime);
10+
bool IsCommandOnCooldownWithCondition(Func<CooldownTimer, bool> predicate, CCSPlayerController player, Commands cmd);
11+
void SetCooldown(CCSPlayerController player, Commands cmd);
12+
}

CustomCommands/Interfaces/IPermissionsManager.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using CounterStrikeSharp.API.Core;
21
using CustomCommands.Model;
32

43
namespace CustomCommands.Interfaces;
@@ -7,4 +6,6 @@ public interface IPluginGlobals
76
List<CenterClientElement> centerClientOn { get; set; }
87
CenterServerElement centerServerOn { get; set; }
98
CustomCommandsConfig Config { get; set; }
9+
List<CooldownTimer> CooldownTimer { get; set; }
10+
List<Commands> CustomCommands { get; set; }
1011
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using CounterStrikeSharp.API.Core;
2+
using CustomCommands.Model;
3+
4+
namespace CustomCommands.Interfaces;
5+
6+
public interface IPluginUtilities
7+
{
8+
string[] SplitStringByCommaOrSemicolon(string str);
9+
void ExecuteServerCommands(Commands cmd, CCSPlayerController player);
10+
bool RequiresPermissions(CCSPlayerController player, Permission permissions);
11+
string PadLeftColorTag(string input);
12+
}

CustomCommands/Interfaces/IRegisterCommands.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ public interface IRegisterCommands
66
{
77
void AddCommands(Commands cmd);
88
List<Commands> CheckForDuplicateCommands(List<Commands> comms);
9-
void ExecuteServerCommands(Commands cmd);
109
}

CustomCommands/Model/CommandsConfig.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
public class Commands
44
{
5+
public Guid ID { get; set; } = Guid.NewGuid();
56
public string Title { get; set; } = "";
67
public string Description { get; set; } = "Description";
78
public string Command { get; set; } = "";
9+
public dynamic Cooldown { get; set; } = 0;
810
public dynamic Message { get; set; } = "";
911
public CenterElement CenterMessage { get; set; } = new();
1012
public Sender PrintTo { get; set; } = Sender.ClientChat;
1113
public List<string> ServerCommands { get; set; } = new();
1214
public Permission Permission { get; set; } = new();
1315
}
16+
public class Cooldown
17+
{
18+
public int CooldownTime { get; set; } = 0;
19+
public bool IsGlobal { get; set; } = false;
20+
public string CooldownMessage { get; set; } = "";
21+
}
1422
public class Permission
1523
{
1624
public bool RequiresAllPermissions { get; set; } = false;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace CustomCommands.Model;
2+
3+
public class CooldownTimer
4+
{
5+
public bool IsGlobal { get; set; } = false;
6+
public int PlayerID { get; set; }
7+
public required Guid CommandID { get; set; }
8+
public required DateTime CooldownTime { get; set; }
9+
}

0 commit comments

Comments
 (0)