mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-09-27 20:17:04 +02:00
1.6.2a
```diff + Added duration and reason menu when admin try to ban/mute without specific time + Added `NotifyPenaltiesToAdminOnConnect` config setting to disable notifications globally + Added immunity check when using game vote to kick player - Removed `Discord.Net.Webhook` package (too heavy) ```
This commit is contained in:
parent
bd817d6652
commit
6847da2af0
20 changed files with 532 additions and 328 deletions
|
|
@ -1,11 +1,11 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.ValveConstants.Protobuf;
|
||||
using CS2_SimpleAdmin.Managers;
|
||||
using CS2_SimpleAdmin.Menus;
|
||||
using CS2_SimpleAdminApi;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
|
|
@ -30,21 +30,22 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Database.Database database = new(DbConnectionString);
|
||||
BanManager banManager = new(database, Config);
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
reason = command.GetArg(3);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
if (!int.TryParse(command.GetArg(2), out var time) && caller != null && caller.IsValid)
|
||||
{
|
||||
Ban(caller, player, time, reason, callerName, banManager, command);
|
||||
DurationMenu.OpenMenu(caller, $"{_localizer?["sa_ban"] ?? "Ban"}: {player.PlayerName}", player,
|
||||
ManagePlayersMenu.BanMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
Ban(caller, player, time, reason, callerName, BanManager, command);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ public partial class CS2_SimpleAdmin
|
|||
// Asynchronously handle banning logic
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await (banManager ??= new BanManager(Database, Config)).BanPlayer(playerInfo, adminInfo, reason, time);
|
||||
await BanManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
// Update banned players list
|
||||
|
|
@ -168,8 +169,7 @@ public partial class CS2_SimpleAdmin
|
|||
// Asynchronous ban operation if player is not online or not found
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var banManager = new BanManager(Database, Config);
|
||||
await banManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
||||
await BanManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Player with steamid {steamid} is not online. Ban has been added offline.");
|
||||
|
|
@ -224,8 +224,7 @@ public partial class CS2_SimpleAdmin
|
|||
// Asynchronous ban operation if player is not online or not found
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var banManager = new BanManager(Database, Config);
|
||||
await banManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
||||
await BanManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Player with ip {ipAddress} is not online. Ban has been added offline.");
|
||||
|
|
@ -269,8 +268,7 @@ public partial class CS2_SimpleAdmin
|
|||
var pattern = command.GetArg(1);
|
||||
var reason = command.GetArg(2);
|
||||
|
||||
BanManager banManager = new(Database, Config);
|
||||
Task.Run(async () => await banManager.UnbanPlayer(pattern, callerSteamId, reason));
|
||||
Task.Run(async () => await BanManager.UnbanPlayer(pattern, callerSteamId, reason));
|
||||
|
||||
Helper.LogCommand(caller, command);
|
||||
|
||||
|
|
@ -406,8 +404,7 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
var pattern = command.GetArg(1);
|
||||
|
||||
WarnManager warnManager = new(Database);
|
||||
Task.Run(async () => await warnManager.UnwarnPlayer(pattern));
|
||||
Task.Run(async () => await WarnManager.UnwarnPlayer(pattern));
|
||||
|
||||
Helper.LogCommand(caller, command);
|
||||
command.ReplyToCommand($"Unwarned player with pattern {pattern}.");
|
||||
|
|
|
|||
|
|
@ -29,16 +29,12 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// Initialize managers
|
||||
MuteManager muteManager = new(Database);
|
||||
WarnManager warnManager = new(Database);
|
||||
|
||||
try
|
||||
{
|
||||
var warns = await warnManager.GetPlayerWarns(PlayersInfo[userId], false);
|
||||
var warns = await WarnManager.GetPlayerWarns(PlayersInfo[userId], false);
|
||||
|
||||
// Check if the player is muted
|
||||
var activeMutes = await muteManager.IsPlayerMuted(PlayersInfo[userId].SteamId.SteamId64.ToString());
|
||||
var activeMutes = await MuteManager.IsPlayerMuted(PlayersInfo[userId].SteamId.SteamId64.ToString());
|
||||
|
||||
Dictionary<PenaltyType, List<string>> mutesList = new()
|
||||
{
|
||||
|
|
@ -221,8 +217,7 @@ public partial class CS2_SimpleAdmin
|
|||
public void RemoveAdmin(CCSPlayerController? caller, string steamid, bool globalDelete = false, CommandInfo? command = null)
|
||||
{
|
||||
if (Database == null) return;
|
||||
PermissionManager adminManager = new(Database);
|
||||
_ = adminManager.DeleteAdminBySteamId(steamid, globalDelete);
|
||||
_ = PermissionManager.DeleteAdminBySteamId(steamid, globalDelete);
|
||||
|
||||
AddTimer(2, () =>
|
||||
{
|
||||
|
|
@ -313,8 +308,7 @@ public partial class CS2_SimpleAdmin
|
|||
private void RemoveGroup(CCSPlayerController? caller, string name, CommandInfo? command = null)
|
||||
{
|
||||
if (Database == null) return;
|
||||
PermissionManager adminManager = new(Database);
|
||||
_ = adminManager.DeleteGroup(name);
|
||||
_ = PermissionManager.DeleteGroup(name);
|
||||
|
||||
AddTimer(2, () =>
|
||||
{
|
||||
|
|
@ -551,9 +545,6 @@ public partial class CS2_SimpleAdmin
|
|||
if (playersToTarget.Count > 1)
|
||||
return;
|
||||
|
||||
Database.Database database = new(DbConnectionString);
|
||||
WarnManager warnManager = new(database);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (!player.UserId.HasValue) return;
|
||||
|
|
@ -565,7 +556,7 @@ public partial class CS2_SimpleAdmin
|
|||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var warnsList = await warnManager.GetPlayerWarns(PlayersInfo[userId], false);
|
||||
var warnsList = await WarnManager.GetPlayerWarns(PlayersInfo[userId], false);
|
||||
var sortedWarns = warnsList
|
||||
.OrderBy(warn => (string)warn.status == "ACTIVE" ? 0 : 1)
|
||||
.ThenByDescending(warn => (int)warn.id)
|
||||
|
|
@ -576,7 +567,7 @@ public partial class CS2_SimpleAdmin
|
|||
warnsMenu?.AddMenuOption($"[{((string)w.status == "ACTIVE" ? $"{ChatColors.LightRed}X" : $"{ChatColors.Lime}✔️")}{ChatColors.Default}] {(string)w.reason}",
|
||||
(controller, option) =>
|
||||
{
|
||||
_ = warnManager.UnwarnPlayer(PlayersInfo[userId], (int)w.id);
|
||||
_ = WarnManager.UnwarnPlayer(PlayersInfo[userId], (int)w.id);
|
||||
player.PrintToChat(_localizer["sa_admin_warns_unwarn", player.PlayerName, (string)w.reason]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using CounterStrikeSharp.API.Core.Attributes.Registration;
|
|||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CS2_SimpleAdmin.Managers;
|
||||
using CS2_SimpleAdmin.Menus;
|
||||
using CS2_SimpleAdminApi;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
|
|
@ -27,20 +28,21 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
reason = command.GetArg(3);
|
||||
|
||||
MuteManager muteManager = new(Database);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
if (!caller!.CanTarget(player)) return;
|
||||
if (!int.TryParse(command.GetArg(2), out var time) && caller != null && caller.IsValid)
|
||||
{
|
||||
Gag(caller, player, time, reason, callerName, muteManager, command);
|
||||
DurationMenu.OpenMenu(caller, $"{_localizer?["sa_gag"] ?? "Gag"}: {player.PlayerName}", player,
|
||||
ManagePlayersMenu.GagMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
Gag(caller, player, time, reason, callerName, MuteManager, command);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +126,6 @@ public partial class CS2_SimpleAdmin
|
|||
? command.GetArg(3)
|
||||
: (_localizer?["sa_unknown"] ?? "Unknown");
|
||||
|
||||
MuteManager muteManager = new(Database);
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
|
||||
// Get player and admin info
|
||||
|
|
@ -140,14 +141,14 @@ public partial class CS2_SimpleAdmin
|
|||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
// Perform the gag for an online player
|
||||
Gag(caller, player, time, reason, callerName, muteManager, silent: true);
|
||||
Gag(caller, player, time, reason, callerName, MuteManager, silent: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Asynchronous gag operation for offline players
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time);
|
||||
await MuteManager.AddMuteBySteamid(steamid, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Player with steamid {steamid} is not online. Gag has been added offline.");
|
||||
|
|
@ -244,19 +245,20 @@ public partial class CS2_SimpleAdmin
|
|||
return;
|
||||
}
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
reason = command.GetArg(3);
|
||||
|
||||
MuteManager muteManager = new(Database);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
if (!caller!.CanTarget(player)) return;
|
||||
if (!int.TryParse(command.GetArg(2), out var time) && caller != null && caller.IsValid)
|
||||
{
|
||||
Mute(caller, player, time, reason, callerName, muteManager, command);
|
||||
DurationMenu.OpenMenu(caller, $"{_localizer?["sa_mute"] ?? "Mute"}: {player.PlayerName}", player,
|
||||
ManagePlayersMenu.MuteMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
Mute(caller, player, time, reason, callerName, MuteManager, command);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -343,7 +345,6 @@ public partial class CS2_SimpleAdmin
|
|||
? command.GetArg(3)
|
||||
: (_localizer?["sa_unknown"] ?? "Unknown");
|
||||
|
||||
MuteManager muteManager = new(Database);
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
|
||||
// Get player and admin info
|
||||
|
|
@ -359,14 +360,14 @@ public partial class CS2_SimpleAdmin
|
|||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
// Perform the mute for an online player
|
||||
Mute(caller, player, time, reason, callerName, muteManager, silent: true);
|
||||
Mute(caller, player, time, reason, callerName, MuteManager, silent: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Asynchronous mute operation for offline players
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 1);
|
||||
await MuteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 1);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Player with steamid {steamid} is not online. Mute has been added offline.");
|
||||
|
|
@ -464,20 +465,21 @@ public partial class CS2_SimpleAdmin
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
reason = command.GetArg(3);
|
||||
|
||||
MuteManager muteManager = new(Database);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
if (!caller!.CanTarget(player)) return;
|
||||
if (!int.TryParse(command.GetArg(2), out var time) && caller != null && caller.IsValid)
|
||||
{
|
||||
Silence(caller, player, time, reason, callerName, muteManager, command);
|
||||
DurationMenu.OpenMenu(caller, $"{_localizer?["sa_silence"] ?? "Silence"}: {player.PlayerName}", player,
|
||||
ManagePlayersMenu.SilenceMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
Silence(caller, player, time, reason, callerName, MuteManager, command);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +564,6 @@ public partial class CS2_SimpleAdmin
|
|||
: (_localizer?["sa_unknown"] ?? "Unknown");
|
||||
|
||||
int.TryParse(command.GetArg(2), out var time);
|
||||
MuteManager muteManager = new(Database);
|
||||
|
||||
// Get player and admin info
|
||||
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
|
||||
|
|
@ -577,14 +578,14 @@ public partial class CS2_SimpleAdmin
|
|||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
// Perform the silence for an online player
|
||||
Silence(caller, player, time, reason, callerName, muteManager, silent: true);
|
||||
Silence(caller, player, time, reason, callerName, MuteManager, silent: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Asynchronous silence operation for offline players
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 2);
|
||||
await MuteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 2);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Player with steamid {steamid} is not online. Silence has been added offline.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue