- New feature permban permission (@css/permban)
- CustomCommand fix
- Version checker
- Minor changes
- Updated to CounterStrikeSharp 225
- Bump version to 1.4.3a
This commit is contained in:
Dawid Bepierszcz
2024-04-30 14:05:20 +02:00
parent 342d4f717f
commit 19f8b68c1c
30 changed files with 308 additions and 255 deletions

View File

@@ -29,7 +29,7 @@ namespace CS2_SimpleAdmin
return;
}
Database database = new(dbConnectionString);
Database.Database database = new(_dbConnectionString);
BanManager banManager = new(database, Config);
int.TryParse(command.GetArg(2), out var time);
@@ -84,10 +84,10 @@ namespace CS2_SimpleAdmin
AddTimer(Config.KickTime, () => Helper.KickPlayer(player.UserId.Value),
CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
if (playerInfo.IpAddress != null && !bannedPlayers.Contains(playerInfo.IpAddress))
bannedPlayers.Add(playerInfo.IpAddress);
if (!bannedPlayers.Contains(player.SteamID.ToString()))
bannedPlayers.Add(player.SteamID.ToString());
if (playerInfo.IpAddress != null && !BannedPlayers.Contains(playerInfo.IpAddress))
BannedPlayers.Add(playerInfo.IpAddress);
if (!BannedPlayers.Contains(player.SteamID.ToString()))
BannedPlayers.Add(player.SteamID.ToString());
if (time == 0)
{
@@ -97,7 +97,7 @@ namespace CS2_SimpleAdmin
player.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || !silentPlayers.Contains(caller.Slot))
if (caller == null || !SilentPlayers.Contains(caller.Slot))
{
foreach (var controller in Helper.GetValidPlayers())
{
@@ -117,7 +117,7 @@ namespace CS2_SimpleAdmin
{
player.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || !silentPlayers.Contains(caller.Slot))
if (caller == null || !SilentPlayers.Contains(caller.Slot))
{
foreach (var controller in Helper.GetValidPlayers())
{
@@ -134,9 +134,9 @@ namespace CS2_SimpleAdmin
if (command != null)
{
Helper.LogCommand(caller, command);
Helper.SendDiscordLogMessage(caller, command, _discordWebhookClientLog, _localizer);
Helper.SendDiscordLogMessage(caller, command, DiscordWebhookClientLog, _localizer);
}
Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, _discordWebhookClientPenalty, _localizer);
Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, DiscordWebhookClientPenalty, _localizer);
}
[ConsoleCommand("css_addban")]
@@ -199,7 +199,7 @@ namespace CS2_SimpleAdmin
{
player.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || !silentPlayers.Contains(caller.Slot))
if (caller == null || !SilentPlayers.Contains(caller.Slot))
{
foreach (var controller in Helper.GetValidPlayers())
{
@@ -220,7 +220,7 @@ namespace CS2_SimpleAdmin
player.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || !silentPlayers.Contains(caller.Slot))
if (caller == null || !SilentPlayers.Contains(caller.Slot))
{
foreach (var controller in Helper.GetValidPlayers())
{
@@ -235,7 +235,7 @@ namespace CS2_SimpleAdmin
}
}
Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, _discordWebhookClientPenalty, _localizer);
Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, DiscordWebhookClientPenalty, _localizer);
}
Task.Run(async () =>
@@ -245,7 +245,7 @@ namespace CS2_SimpleAdmin
});
Helper.LogCommand(caller, command);
Helper.SendDiscordLogMessage(caller, command, _discordWebhookClientLog, _localizer);
Helper.SendDiscordLogMessage(caller, command, DiscordWebhookClientLog, _localizer);
//Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, _discordWebhookClientPenalty, _localizer);
command.ReplyToCommand($"Banned player with steamid {steamid}.");
@@ -271,7 +271,7 @@ namespace CS2_SimpleAdmin
return;
}
Helper.SendDiscordLogMessage(caller, command, _discordWebhookClientLog, _localizer);
Helper.SendDiscordLogMessage(caller, command, DiscordWebhookClientLog, _localizer);
var reason = _localizer?["sa_unknown"] ?? "Unknown";
@@ -311,7 +311,7 @@ namespace CS2_SimpleAdmin
player.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || !silentPlayers.Contains(caller.Slot))
if (caller == null || !SilentPlayers.Contains(caller.Slot))
{
foreach (var controller in Helper.GetValidPlayers())
{
@@ -331,7 +331,7 @@ namespace CS2_SimpleAdmin
{
player.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
}
if (caller == null || !silentPlayers.Contains(caller.Slot))
if (caller == null || !SilentPlayers.Contains(caller.Slot))
{
foreach (var controller in Helper.GetValidPlayers())
{
@@ -353,7 +353,7 @@ namespace CS2_SimpleAdmin
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
}
}
Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, _discordWebhookClientPenalty, _localizer);
Helper.SendDiscordPenaltyMessage(caller, player, reason, time, Helper.PenaltyType.Ban, DiscordWebhookClientPenalty, _localizer);
}
Task.Run(async () =>
@@ -363,32 +363,28 @@ namespace CS2_SimpleAdmin
});
Helper.LogCommand(caller, command);
Helper.SendDiscordLogMessage(caller, command, _discordWebhookClientLog, _localizer);
Helper.SendDiscordLogMessage(caller, command, DiscordWebhookClientLog, _localizer);
command.ReplyToCommand($"Banned player with IP address {ipAddress}.");
}
private bool CheckValidBan(CCSPlayerController? caller, int duration)
{
bool validCaller = caller != null && caller.IsValid;
if (caller == null) return true;
bool canPermBan = caller == null || validCaller && AdminManager.PlayerHasPermissions(caller, "@css/permban");
bool canPermBan = AdminManager.PlayerHasPermissions(caller, "@css/permban");
if (duration > Config.MaxBanDuration && canPermBan == false)
{
if (validCaller)
caller.PrintToChat($"{_localizer["sa_prefix"]} {_localizer["sa_ban_max_duration_exceeded", Config.MaxBanDuration]}");
return false;
caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_max_duration_exceeded", Config.MaxBanDuration]}");
}
if (duration == 0 && canPermBan == false)
{
if (validCaller)
caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_perm_restricted"]}");
return false;
caller.PrintToChat($"{_localizer!["sa_prefix"]} {_localizer["sa_ban_perm_restricted"]}");
}
return true;
return caller.IsValid && canPermBan;
}
[ConsoleCommand("css_unban")]
@@ -412,7 +408,7 @@ namespace CS2_SimpleAdmin
BanManager banManager = new(_database, Config);
Task.Run(async () => await banManager.UnbanPlayer(pattern, callerSteamId, reason));
Helper.SendDiscordLogMessage(caller, command, _discordWebhookClientLog, _localizer);
Helper.SendDiscordLogMessage(caller, command, DiscordWebhookClientLog, _localizer);
Helper.LogCommand(caller, command);
command.ReplyToCommand($"Unbanned player with pattern {pattern}.");