Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Total upgrade V3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Feb 1, 2024
1 parent 6f4b8a1 commit c3522f4
Show file tree
Hide file tree
Showing 30 changed files with 1,318 additions and 1,287 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
-- 2023.01.30 - V3.3.0

- feat: Add MySQL pooling support
- feat: Add custom MySQL wrapper
- feat: Add transaction support for save/load
- feat: Customizable no permission message
- feat: Customizable client only command message
- feat: Customizable server only command message
- fix: Commands not deleted on hotReload
- refactor: Create global cache loader
- refactor: Create global cache saver
- refactor: Use reusable MySQL connection
- refactor: Replace lambda command helpers with custom logic

-- 2023.01.30 - V3.2.0

- feat: Add starting point settings for new players ([#129](https://github.com/K4ryuu/K4-System/issues/129))
Expand Down
2 changes: 1 addition & 1 deletion src/K4-System.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Nexd.MySQL" Version="*" />
<PackageReference Include="MySqlConnector" Version="*" />
<PackageReference Include="Newtonsoft.Json" Version="*" />
</ItemGroup>
<ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions src/Module/Interfaces/IModuleRank.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;
using static K4System.ModuleRank;

namespace K4System
{
public interface IModuleRank
{
public void Initialize(bool hotReload);

public void Release(bool hotReload);

public Rank GetNoneRank();

public void LoadRankData(int slot, int points);

public void BeforeRoundEnd(int winnerTeam);

public void OnCommandRank(CCSPlayerController? player, CommandInfo info);

public void OnCommandRanks(CCSPlayerController? player, CommandInfo info);

public void OnCommandResetMyRank(CCSPlayerController? player, CommandInfo info);

public void OnCommandTop(CCSPlayerController? player, CommandInfo info);

public void OnCommandResetRank(CCSPlayerController? player, CommandInfo info);

public void OnCommandSetPoints(CCSPlayerController? player, CommandInfo info);

public void OnCommandGivePoints(CCSPlayerController? player, CommandInfo info);

public void OnCommandRemovePoints(CCSPlayerController? player, CommandInfo info);
}
}
9 changes: 9 additions & 0 deletions src/Module/Interfaces/IModuleStat.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;

namespace K4System
{
public interface IModuleStat
{
public void Initialize(bool hotReload);

public void Release(bool hotReload);

public void LoadStatData(int slot, Dictionary<string, int> statData);

public void BeforeRoundEnd(int winnerTeam);

public void OnCommandStats(CCSPlayerController? player, CommandInfo info);
}
}
9 changes: 9 additions & 0 deletions src/Module/Interfaces/IModuleTime.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;

namespace K4System
{
public interface IModuleTime
{
public void Initialize(bool hotReload);

public void Release(bool hotReload);

public void LoadTimeData(int slot, Dictionary<string, int> timeData);

public void BeforeDisconnect(CCSPlayerController player);

public void OnCommandTime(CCSPlayerController? player, CommandInfo info);
}
}
5 changes: 5 additions & 0 deletions src/Module/Interfaces/IModuleUtils.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;

namespace K4System
{
public interface IModuleUtils
{
public void Initialize(bool hotReload);

public void Release(bool hotReload);

public void OnCommandAdmins(CCSPlayerController? player, CommandInfo info);
}
}
22 changes: 0 additions & 22 deletions src/Module/ModuleRank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,8 @@ public void Initialize(bool hotReload)
Plugin plugin = (this.PluginContext.Plugin as Plugin)!;

this.Config = plugin.Config;
this.Database = plugin.Database;
this.ModuleDirectory = plugin._ModuleDirectory;

//** ? Initialize Database */

if (!plugin.InitializeDatabase("k4ranks", $@"
CREATE TABLE IF NOT EXISTS `{this.Config.DatabaseSettings.TablePrefix}k4ranks` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`steam_id` VARCHAR(32) COLLATE 'utf8mb4_unicode_ci' UNIQUE NOT NULL,
`name` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
`rank` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
`points` INT NOT NULL DEFAULT 0,
UNIQUE (`steam_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"))
{
return;
}

//** ? Register Module Parts */

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

if (hotReload)
{
LoadAllPlayerCache();

globalGameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First().GameRules;

plugin.AddTimer(Config.PointSettings.PlaytimeMinutes * 60, () =>
Expand All @@ -78,10 +60,6 @@ public void Initialize(bool hotReload)
public void Release(bool hotReload)
{
this.Logger.LogInformation("Releasing '{0}'", this.GetType().Name);

//** ? Save Player Caches */

SaveAllPlayerCache(true);
}
}
}
34 changes: 0 additions & 34 deletions src/Module/ModuleStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,6 @@ public void Initialize(bool hotReload)
Plugin plugin = (this.PluginContext.Plugin as Plugin)!;

this.Config = plugin.Config;
this.Database = plugin.Database;

//** ? Initialize Database */

if (!plugin.InitializeDatabase("k4stats", $@"CREATE TABLE IF NOT EXISTS `{this.Config.DatabaseSettings.TablePrefix}k4stats` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`steam_id` VARCHAR(32) COLLATE 'utf8mb4_unicode_ci' UNIQUE NOT NULL,
`name` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
`lastseen` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`kills` INT NOT NULL DEFAULT 0,
`firstblood` INT NOT NULL DEFAULT 0,
`deaths` INT NOT NULL DEFAULT 0,
`assists` INT NOT NULL DEFAULT 0,
`shoots` INT NOT NULL DEFAULT 0,
`hits_taken` INT NOT NULL DEFAULT 0,
`hits_given` INT NOT NULL DEFAULT 0,
`headshots` INT NOT NULL DEFAULT 0,
`grenades` INT NOT NULL DEFAULT 0,
`mvp` INT NOT NULL DEFAULT 0,
`round_win` INT NOT NULL DEFAULT 0,
`round_lose` INT NOT NULL DEFAULT 0,
`game_win` INT NOT NULL DEFAULT 0,
`game_lose` INT NOT NULL DEFAULT 0,
UNIQUE (`steam_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"))
{
return;
}

//** ? Register Module Parts */

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

if (hotReload)
{
LoadAllPlayerCache();

globalGameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First().GameRules;
}
}

public void Release(bool hotReload)
{
this.Logger.LogInformation("Releasing '{0}'", this.GetType().Name);

//** ? Save Player Caches */

SaveAllPlayerCache(true);
}
}
}
32 changes: 0 additions & 32 deletions src/Module/ModuleTime.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace K4System
{
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Plugin;

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

this.Config = plugin.Config;
this.Database = plugin.Database;

//** ? Initialize Database */

if (!plugin.InitializeDatabase("k4times", @$"CREATE TABLE IF NOT EXISTS `{this.Config.DatabaseSettings.TablePrefix}k4times` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`steam_id` VARCHAR(32) COLLATE 'utf8mb4_unicode_ci' UNIQUE NOT NULL,
`name` VARCHAR(255) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
`all` INT NOT NULL DEFAULT 0,
`ct` INT NOT NULL DEFAULT 0,
`t` INT NOT NULL DEFAULT 0,
`spec` INT NOT NULL DEFAULT 0,
`dead` INT NOT NULL DEFAULT 0,
`alive` INT NOT NULL DEFAULT 0,
UNIQUE (`steam_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"))
{
return;
}

//** ? Register Module Parts */

Initialize_Events(plugin);
Initialize_Commands(plugin);

//** ? Hot Reload Events */

if (hotReload)
{
LoadAllPlayerCache();
}
}

public void Release(bool hotReload)
{
this.Logger.LogInformation("Releasing '{0}'", this.GetType().Name);

//** ? Save Player Caches */

SaveAllPlayerCache(true);
}
}
}
Loading

0 comments on commit c3522f4

Please sign in to comment.