Skip to content
This repository was archived by the owner on Jan 25, 2025. It is now read-only.

Commit c3522f4

Browse files
committed
Total upgrade V3.3.0
1 parent 6f4b8a1 commit c3522f4

30 files changed

+1318
-1287
lines changed

CHANGELOG

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
-- 2023.01.30 - V3.3.0
2+
3+
- feat: Add MySQL pooling support
4+
- feat: Add custom MySQL wrapper
5+
- feat: Add transaction support for save/load
6+
- feat: Customizable no permission message
7+
- feat: Customizable client only command message
8+
- feat: Customizable server only command message
9+
- fix: Commands not deleted on hotReload
10+
- refactor: Create global cache loader
11+
- refactor: Create global cache saver
12+
- refactor: Use reusable MySQL connection
13+
- refactor: Replace lambda command helpers with custom logic
14+
115
-- 2023.01.30 - V3.2.0
216

317
- feat: Add starting point settings for new players ([#129](https://github.com/K4ryuu/K4-System/issues/129))

src/K4-System.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<ExcludeAssets>runtime</ExcludeAssets>
1616
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
</PackageReference>
18-
<PackageReference Include="Nexd.MySQL" Version="*" />
18+
<PackageReference Include="MySqlConnector" Version="*" />
1919
<PackageReference Include="Newtonsoft.Json" Version="*" />
2020
</ItemGroup>
2121
<ItemGroup>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1+
using CounterStrikeSharp.API.Core;
2+
using CounterStrikeSharp.API.Modules.Commands;
3+
using static K4System.ModuleRank;
4+
15
namespace K4System
26
{
37
public interface IModuleRank
48
{
59
public void Initialize(bool hotReload);
610

711
public void Release(bool hotReload);
12+
13+
public Rank GetNoneRank();
14+
15+
public void LoadRankData(int slot, int points);
16+
17+
public void BeforeRoundEnd(int winnerTeam);
18+
19+
public void OnCommandRank(CCSPlayerController? player, CommandInfo info);
20+
21+
public void OnCommandRanks(CCSPlayerController? player, CommandInfo info);
22+
23+
public void OnCommandResetMyRank(CCSPlayerController? player, CommandInfo info);
24+
25+
public void OnCommandTop(CCSPlayerController? player, CommandInfo info);
26+
27+
public void OnCommandResetRank(CCSPlayerController? player, CommandInfo info);
28+
29+
public void OnCommandSetPoints(CCSPlayerController? player, CommandInfo info);
30+
31+
public void OnCommandGivePoints(CCSPlayerController? player, CommandInfo info);
32+
33+
public void OnCommandRemovePoints(CCSPlayerController? player, CommandInfo info);
834
}
935
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
using CounterStrikeSharp.API.Core;
2+
using CounterStrikeSharp.API.Modules.Commands;
3+
14
namespace K4System
25
{
36
public interface IModuleStat
47
{
58
public void Initialize(bool hotReload);
69

710
public void Release(bool hotReload);
11+
12+
public void LoadStatData(int slot, Dictionary<string, int> statData);
13+
14+
public void BeforeRoundEnd(int winnerTeam);
15+
16+
public void OnCommandStats(CCSPlayerController? player, CommandInfo info);
817
}
918
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
using CounterStrikeSharp.API.Core;
2+
using CounterStrikeSharp.API.Modules.Commands;
3+
14
namespace K4System
25
{
36
public interface IModuleTime
47
{
58
public void Initialize(bool hotReload);
69

710
public void Release(bool hotReload);
11+
12+
public void LoadTimeData(int slot, Dictionary<string, int> timeData);
13+
14+
public void BeforeDisconnect(CCSPlayerController player);
15+
16+
public void OnCommandTime(CCSPlayerController? player, CommandInfo info);
817
}
918
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
using CounterStrikeSharp.API.Core;
2+
using CounterStrikeSharp.API.Modules.Commands;
3+
14
namespace K4System
25
{
36
public interface IModuleUtils
47
{
58
public void Initialize(bool hotReload);
69

710
public void Release(bool hotReload);
11+
12+
public void OnCommandAdmins(CCSPlayerController? player, CommandInfo info);
813
}
914
}

src/Module/ModuleRank.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,8 @@ public void Initialize(bool hotReload)
2424
Plugin plugin = (this.PluginContext.Plugin as Plugin)!;
2525

2626
this.Config = plugin.Config;
27-
this.Database = plugin.Database;
2827
this.ModuleDirectory = plugin._ModuleDirectory;
2928

30-
//** ? Initialize Database */
31-
32-
if (!plugin.InitializeDatabase("k4ranks", $@"
33-
CREATE TABLE IF NOT EXISTS `{this.Config.DatabaseSettings.TablePrefix}k4ranks` (
34-
`id` INT AUTO_INCREMENT PRIMARY KEY,
35-
`steam_id` VARCHAR(32) COLLATE 'utf8mb4_unicode_ci' UNIQUE NOT NULL,
36-
`name` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
37-
`rank` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
38-
`points` INT NOT NULL DEFAULT 0,
39-
UNIQUE (`steam_id`)
40-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"))
41-
{
42-
return;
43-
}
44-
4529
//** ? Register Module Parts */
4630

4731
Initialize_Config(plugin);
@@ -53,8 +37,6 @@ public void Initialize(bool hotReload)
5337

5438
if (hotReload)
5539
{
56-
LoadAllPlayerCache();
57-
5840
globalGameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First().GameRules;
5941

6042
plugin.AddTimer(Config.PointSettings.PlaytimeMinutes * 60, () =>
@@ -78,10 +60,6 @@ public void Initialize(bool hotReload)
7860
public void Release(bool hotReload)
7961
{
8062
this.Logger.LogInformation("Releasing '{0}'", this.GetType().Name);
81-
82-
//** ? Save Player Caches */
83-
84-
SaveAllPlayerCache(true);
8563
}
8664
}
8765
}

src/Module/ModuleStat.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,6 @@ public void Initialize(bool hotReload)
2323
Plugin plugin = (this.PluginContext.Plugin as Plugin)!;
2424

2525
this.Config = plugin.Config;
26-
this.Database = plugin.Database;
27-
28-
//** ? Initialize Database */
29-
30-
if (!plugin.InitializeDatabase("k4stats", $@"CREATE TABLE IF NOT EXISTS `{this.Config.DatabaseSettings.TablePrefix}k4stats` (
31-
`id` INT AUTO_INCREMENT PRIMARY KEY,
32-
`steam_id` VARCHAR(32) COLLATE 'utf8mb4_unicode_ci' UNIQUE NOT NULL,
33-
`name` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
34-
`lastseen` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
35-
`kills` INT NOT NULL DEFAULT 0,
36-
`firstblood` INT NOT NULL DEFAULT 0,
37-
`deaths` INT NOT NULL DEFAULT 0,
38-
`assists` INT NOT NULL DEFAULT 0,
39-
`shoots` INT NOT NULL DEFAULT 0,
40-
`hits_taken` INT NOT NULL DEFAULT 0,
41-
`hits_given` INT NOT NULL DEFAULT 0,
42-
`headshots` INT NOT NULL DEFAULT 0,
43-
`grenades` INT NOT NULL DEFAULT 0,
44-
`mvp` INT NOT NULL DEFAULT 0,
45-
`round_win` INT NOT NULL DEFAULT 0,
46-
`round_lose` INT NOT NULL DEFAULT 0,
47-
`game_win` INT NOT NULL DEFAULT 0,
48-
`game_lose` INT NOT NULL DEFAULT 0,
49-
UNIQUE (`steam_id`)
50-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"))
51-
{
52-
return;
53-
}
5426

5527
//** ? Register Module Parts */
5628

@@ -61,19 +33,13 @@ public void Initialize(bool hotReload)
6133

6234
if (hotReload)
6335
{
64-
LoadAllPlayerCache();
65-
6636
globalGameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First().GameRules;
6737
}
6838
}
6939

7040
public void Release(bool hotReload)
7141
{
7242
this.Logger.LogInformation("Releasing '{0}'", this.GetType().Name);
73-
74-
//** ? Save Player Caches */
75-
76-
SaveAllPlayerCache(true);
7743
}
7844
}
7945
}

src/Module/ModuleTime.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
namespace K4System
22
{
3-
using CounterStrikeSharp.API;
4-
using CounterStrikeSharp.API.Core;
53
using CounterStrikeSharp.API.Core.Plugin;
64

75
using Microsoft.Extensions.Logging;
@@ -23,46 +21,16 @@ public void Initialize(bool hotReload)
2321
Plugin plugin = (this.PluginContext.Plugin as Plugin)!;
2422

2523
this.Config = plugin.Config;
26-
this.Database = plugin.Database;
27-
28-
//** ? Initialize Database */
29-
30-
if (!plugin.InitializeDatabase("k4times", @$"CREATE TABLE IF NOT EXISTS `{this.Config.DatabaseSettings.TablePrefix}k4times` (
31-
`id` INT AUTO_INCREMENT PRIMARY KEY,
32-
`steam_id` VARCHAR(32) COLLATE 'utf8mb4_unicode_ci' UNIQUE NOT NULL,
33-
`name` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
34-
`all` INT NOT NULL DEFAULT 0,
35-
`ct` INT NOT NULL DEFAULT 0,
36-
`t` INT NOT NULL DEFAULT 0,
37-
`spec` INT NOT NULL DEFAULT 0,
38-
`dead` INT NOT NULL DEFAULT 0,
39-
`alive` INT NOT NULL DEFAULT 0,
40-
UNIQUE (`steam_id`)
41-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"))
42-
{
43-
return;
44-
}
4524

4625
//** ? Register Module Parts */
4726

4827
Initialize_Events(plugin);
4928
Initialize_Commands(plugin);
50-
51-
//** ? Hot Reload Events */
52-
53-
if (hotReload)
54-
{
55-
LoadAllPlayerCache();
56-
}
5729
}
5830

5931
public void Release(bool hotReload)
6032
{
6133
this.Logger.LogInformation("Releasing '{0}'", this.GetType().Name);
62-
63-
//** ? Save Player Caches */
64-
65-
SaveAllPlayerCache(true);
6634
}
6735
}
6836
}

0 commit comments

Comments
 (0)