mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-06 23:27:24 +00:00
Added max ban duration and perm ban right
This commit is contained in:
@@ -51,6 +51,9 @@ namespace CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (_database == null || player is null || !player.IsValid) return;
|
if (_database == null || player is null || !player.IsValid) return;
|
||||||
|
|
||||||
|
if (CheckValidBan(caller, time) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (player.PawnIsAlive)
|
if (player.PawnIsAlive)
|
||||||
@@ -143,6 +146,7 @@ namespace CS2_SimpleAdmin
|
|||||||
public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null) return;
|
||||||
|
|
||||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||||
if (command.ArgCount < 2)
|
if (command.ArgCount < 2)
|
||||||
return;
|
return;
|
||||||
@@ -163,6 +167,9 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
int.TryParse(command.GetArg(2), out int time);
|
int.TryParse(command.GetArg(2), out int time);
|
||||||
|
|
||||||
|
if (CheckValidBan(caller, time) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||||
reason = command.GetArg(3);
|
reason = command.GetArg(3);
|
||||||
|
|
||||||
@@ -283,6 +290,8 @@ namespace CS2_SimpleAdmin
|
|||||||
};
|
};
|
||||||
|
|
||||||
int.TryParse(command.GetArg(2), out int time);
|
int.TryParse(command.GetArg(2), out int time);
|
||||||
|
if (CheckValidBan(caller, time) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||||
reason = command.GetArg(3);
|
reason = command.GetArg(3);
|
||||||
@@ -369,6 +378,26 @@ namespace CS2_SimpleAdmin
|
|||||||
command?.ReplyToCommand($"Banned player with IP address {ipAddress}.");
|
command?.ReplyToCommand($"Banned player with IP address {ipAddress}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckValidBan(CCSPlayerController? caller, int duration)
|
||||||
|
{
|
||||||
|
bool validCaller = caller != null && caller.IsValid;
|
||||||
|
|
||||||
|
if (duration > Config.MaxBanDuration)
|
||||||
|
{
|
||||||
|
if (validCaller)
|
||||||
|
caller.PrintToChat($"[Simple Admin] Ban duration cannot exceed {Config.MaxBanDuration} minutes.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duration == 0 && validCaller && AdminManager.PlayerHasPermissions(caller, "@css/permban") == false)
|
||||||
|
{
|
||||||
|
caller.PrintToChat($"[Simple Admin] You do not have the right to permanently ban.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_unban")]
|
[ConsoleCommand("css_unban")]
|
||||||
[RequiresPermissions("@css/unban")]
|
[RequiresPermissions("@css/unban")]
|
||||||
[CommandHelper(minArgs: 1, usage: "<steamid or name or ip> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<steamid or name or ip> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ namespace CS2_SimpleAdmin
|
|||||||
[JsonPropertyName("DisableDangerousCommands")]
|
[JsonPropertyName("DisableDangerousCommands")]
|
||||||
public bool DisableDangerousCommands { get; set; } = true;
|
public bool DisableDangerousCommands { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("MaxBanDuration")]
|
||||||
|
public int MaxBanDuration { get; set; } = 60 * 24 * 7; // 7 days
|
||||||
|
|
||||||
[JsonPropertyName("BanType")]
|
[JsonPropertyName("BanType")]
|
||||||
public int BanType { get; set; } = 1;
|
public int BanType { get; set; } = 1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user