Skip to content

Commit 9b12f55

Browse files
committed
Add punishments support.
1 parent 40b7ff3 commit 9b12f55

19 files changed

+1362
-104
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
mkdir -p addons/counterstrikesharp/plugins/${{env.PLUGIN_NAME}}
4040
mv BasicAdmin/bin/Debug/net7.0/publish/* addons/counterstrikesharp/plugins/${{env.PLUGIN_NAME}}
4141
cd addons/counterstrikesharp/plugins/${{env.PLUGIN_NAME}}
42-
rm CounterStrikeSharp.API.dll McMaster.NETCore.Plugins.dll Microsoft.DotNet.PlatformAbstractions.dll Microsoft.Extensions.DependencyModel.dll ${{env.PLUGIN_NAME}}.pdb
42+
find . -maxdepth 1 ! -name 'BasicAdmin.dll' ! -name 'MySqlConnector.dll' ! -name 'schema.sql' ! -name '.' -type f,d -exec rm -rf {} +
4343
4444
- uses: actions/upload-artifact@v3
4545
with:

BasicAdmin/BasicAdmin.cs

Lines changed: 178 additions & 60 deletions
Large diffs are not rendered by default.

BasicAdmin/BasicAdmin.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.98" />
10+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.128" />
11+
<PackageReference Include="MySqlConnector" Version="2.3.1" />
12+
</ItemGroup>
13+
<ItemGroup>
14+
<None Update="lang\**\*.*" CopyToOutputDirectory="PreserveNewest" />
15+
<None Update="schema.sql" CopyToOutputDirectory="PreserveNewest" />
1116
</ItemGroup>
1217
</Project>

BasicAdmin/BasicAdminConfig.cs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,56 @@
44

55
namespace BasicAdmin;
66

7+
public class PunishmentDefaults
8+
{
9+
[JsonPropertyName("ban_duration")]
10+
public int BanDuration { get; set; } = 30;
11+
12+
[JsonPropertyName("gag_duration")]
13+
public int GagDuration { get; set; } = 30;
14+
15+
[JsonPropertyName("mute_duration")]
16+
public int MuteDuration { get; set; } = 30;
17+
}
18+
19+
public class BasicAdminPunishmentsConfig
20+
{
21+
[JsonPropertyName("defaults")]
22+
public PunishmentDefaults Defaults { get; set; } = new();
23+
}
24+
25+
public sealed class BasicAdminDatabaseConfig
26+
{
27+
[JsonPropertyName("host")]
28+
public string Host { get; set; } = "localhost";
29+
30+
[JsonPropertyName("username")]
31+
public string Username { get; set; } = "user";
32+
33+
[JsonPropertyName("password")]
34+
public string Password { get; set; } = "pass";
35+
36+
[JsonPropertyName("database")]
37+
public string Database { get; set; } = "db_name";
38+
39+
[JsonPropertyName("tablePrefix")]
40+
public string TablePrefix { get; set; } = "ba_";
41+
42+
[JsonPropertyName("port")]
43+
public int Port { get; set; } = 3306;
44+
45+
/// <summary>
46+
/// Server ID on the database.
47+
/// </summary>
48+
[JsonPropertyName("serverId")]
49+
public int ServerId { get; set; } = -1;
50+
51+
public string GetDslString()
52+
{
53+
return $"Server={Host};Database={Database};User Id={Username};Password={Password};Port={Port}";
54+
}
55+
}
56+
757
public class BasicAdminConfig : BasePluginConfig
858
{
959
[JsonPropertyName("admin_tag")]
@@ -26,4 +76,13 @@ public class BasicAdminConfig : BasePluginConfig
2676

2777
[JsonPropertyName("freeze_duration")]
2878
public int FreezeDuration { get; set; } = 5;
29-
}
79+
80+
/// <summary>
81+
/// Database config.
82+
/// </summary>
83+
[JsonPropertyName("database")]
84+
public BasicAdminDatabaseConfig Database { get; set; } = new BasicAdminDatabaseConfig();
85+
86+
[JsonPropertyName("punishments")]
87+
public BasicAdminPunishmentsConfig Punishments { get; set; } = new ();
88+
}

0 commit comments

Comments
 (0)