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

Commit

Permalink
Release v4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Apr 11, 2024
1 parent bf1e7bf commit 92cbfe9
Show file tree
Hide file tree
Showing 39 changed files with 1,522 additions and 1,579 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
-- 2023.04.11 - V4.1.0

- feat: Add Reset option for all module
- feat: Add 25 new statistics
- feat: Add new API endpoints
- fix: Rank name not updating in MySQL
- fix: Admin shows a user multiple times
- fix: Toplist and Rank command lag spikes
- fix: Rank resets sets 0 instead of starting points
- fix: AutoPurge delete freshly moved database
- fix: Add loading message to commands where needed
- optimise: The full plugins code
- upgrade: Changed support from NET7 to NET8

-- 2023.03.28 - V4.0.4

- fix: Table generation problems because of lastseen default value
Expand Down
16 changes: 12 additions & 4 deletions K4-SharedApi/src/K4-SharedApi.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
namespace K4SharedApi
using CounterStrikeSharp.API.Core;

namespace K4SharedApi
{
public interface IK4SharedApi
public interface IPlayerAPI
{
int PlayerPoints { get; }
int PlayerRankID { get; }
bool IsLoaded { get; }
bool IsValid { get; }
bool IsPlayer { get; }
CCSPlayerController Controller { get; }
int Points { get; set; }
int RankID { get; }
string RankName { get; }
string RankClanTag { get; }
}
}
9 changes: 8 additions & 1 deletion K4-SharedApi/src/K4-SharedApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
<PublishDir>./</PublishDir>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>K4_SharedApi</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="*">
<PrivateAssets>none</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Binary file modified K4-SharedApi/src/K4-SharedApi.dll
Binary file not shown.
7 changes: 4 additions & 3 deletions K4-System/src/K4-System.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
<PublishDir>./bin/K4-System/plugins/K4-System</PublishDir>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.198">
<PackageReference Include="CounterStrikeSharp.API" Version="*">
<PrivateAssets>none</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MaxMind.GeoIP2" Version="5.2.0" />
<PackageReference Include="MaxMind.GeoIP2" Version="*" />
<PackageReference Include="MySqlConnector" Version="*" />
<PackageReference Include="Dapper" Version="*" />
<PackageReference Include="Newtonsoft.Json" Version="*" />
<Reference Include="SharedApi">
<HintPath>../../K4-SharedApi/src/K4-SharedApi.dll</HintPath>
Expand Down
61 changes: 61 additions & 0 deletions K4-System/src/Models/PlayerModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;
using static K4System.ModuleRank;
using static K4System.ModuleStat;
using static K4System.ModuleTime;

namespace K4System.Models;

public class K4Player
{
//** ? Main */
private readonly Plugin Plugin;

//** ? Player */
public readonly CCSPlayerController Controller;
public readonly ulong SteamID;
public readonly string PlayerName;

//** ? Data */
public RankData? rankData { get; set; }
public StatData? statData { get; set; }
public TimeData? timeData { get; set; }
public (int killStreak, DateTime lastKillTime) KillStreak = (0, DateTime.MinValue);

public K4Player(Plugin plugin, CCSPlayerController playerController)
{
Plugin = plugin;

Controller = playerController;
SteamID = playerController.SteamID;
PlayerName = playerController.PlayerName;
}

public bool IsValid
{
get
{
return Controller?.IsValid == true && Controller.PlayerPawn?.IsValid == true && Controller.Connected == PlayerConnectedState.PlayerConnected;
}
}

public bool IsPlayer
{
get
{
return !Controller.IsBot && !Controller.IsHLTV;
}
}

public string ClanTag
{
get { return Controller.Clan; }
set
{
Controller.Clan = value;
Utilities.SetStateChanged(Controller, "CCSPlayerController", "m_szClan");
}
}
}
3 changes: 2 additions & 1 deletion K4-System/src/Module/Interfaces/IModuleTime.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CounterStrikeSharp.API.Core;
using K4System.Models;

namespace K4System;

Expand All @@ -8,5 +9,5 @@ public interface IModuleTime

public void Release(bool hotReload);

public void BeforeDisconnect(CCSPlayerController player);
public void BeforeDisconnect(K4Player k4player);
}
30 changes: 15 additions & 15 deletions K4-System/src/Module/ModuleRank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ namespace K4System
using CounterStrikeSharp.API.Core.Plugin;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
using K4System.Models;

public partial class ModuleRank : IModuleRank
{
public ModuleRank(ILogger<ModuleRank> logger, IPluginContext pluginContext)
{
this.Logger = logger;
this.PluginContext = (pluginContext as PluginContext)!;
this.plugin = (pluginContext.Plugin as Plugin)!;
this.Config = plugin.Config;
}

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

//** ? Forwarded Variables */

Plugin plugin = (this.PluginContext.Plugin as Plugin)!;

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

//** ? Register Module Parts */

Initialize_Config(plugin);
Initialize_Menus(plugin);
Initialize_Events(plugin);
Initialize_Commands(plugin);
Initialize_Config();
Initialize_Menus();
Initialize_Events();
Initialize_Commands();

//** ? Register Timers */

plugin.AddTimer(Config.PointSettings.PlaytimeMinutes * 60, () =>
{
Utilities.GetPlayers().Where(p => p.TeamNum == (int)CsTeam.Terrorist)
.ToList()
.ForEach(p => ModifyPlayerPoints(p, Config.PointSettings.PlaytimePoints, "k4.phrases.playtime"));
foreach (K4Player k4player in plugin.K4Players)
{
if (!k4player.IsValid || !k4player.IsPlayer)
continue;
if (k4player.Controller.Team == CsTeam.Terrorist)
ModifyPlayerPoints(k4player, Config.PointSettings.PlaytimePoints, "k4.phrases.playtime");
}
}, TimerFlags.REPEAT);
}

Expand Down
13 changes: 4 additions & 9 deletions K4-System/src/Module/ModuleStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ public partial class ModuleStat : IModuleStat
public ModuleStat(ILogger<ModuleStat> logger, IPluginContext pluginContext)
{
this.Logger = logger;
this.PluginContext = (pluginContext as PluginContext)!;
this.plugin = (pluginContext.Plugin as Plugin)!;
this.Config = plugin.Config;
}

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

//** ? Forwarded Variables */

Plugin plugin = (this.PluginContext.Plugin as Plugin)!;

this.Config = plugin.Config;

//** ? Register Module Parts */

Initialize_Events(plugin);
Initialize_Commands(plugin);
Initialize_Events();
Initialize_Commands();
}

public void Release(bool hotReload)
Expand Down
13 changes: 4 additions & 9 deletions K4-System/src/Module/ModuleTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ public partial class ModuleTime : IModuleTime
public ModuleTime(ILogger<ModuleTime> logger, IPluginContext pluginContext)
{
this.Logger = logger;
this.PluginContext = (pluginContext as PluginContext)!;
this.plugin = (pluginContext.Plugin as Plugin)!;
this.Config = plugin.Config;
}

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

//** ? Forwarded Variables */

Plugin plugin = (this.PluginContext.Plugin as Plugin)!;

this.Config = plugin.Config;

//** ? Register Module Parts */

Initialize_Events(plugin);
Initialize_Commands(plugin);
Initialize_Events();
Initialize_Commands();
}

public void Release(bool hotReload)
Expand Down
11 changes: 3 additions & 8 deletions K4-System/src/Module/ModuleUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,17 @@ public partial class ModuleUtils : IModuleUtils
public ModuleUtils(ILogger<ModuleUtils> logger, IPluginContext pluginContext)
{
this.Logger = logger;
this.PluginContext = (pluginContext as PluginContext)!;
this.plugin = (pluginContext.Plugin as Plugin)!;
this.Config = plugin.Config;
}

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

//** ? Forwarded Variables */

Plugin plugin = (this.PluginContext.Plugin as Plugin)!;

this.Config = plugin.Config;

//** ? Register Module Parts */

Initialize_Commands(plugin);
Initialize_Commands();
}

public void Release(bool hotReload)
Expand Down
Loading

0 comments on commit 92cbfe9

Please sign in to comment.