Antag Rolebans (#35966)

Co-authored-by: beck-thompson <beck314159@hotmail.com>
Co-authored-by: Hannah Giovanna Dawson <karakkaraz@gmail.com>
This commit is contained in:
Errant
2025-09-17 23:59:07 +02:00
committed by GitHub
parent e1ba33814b
commit b692b6e33e
33 changed files with 898 additions and 283 deletions

View File

@@ -1,4 +1,3 @@
using System.Collections.Immutable;
using System.Net;
using System.Threading.Tasks;
using Content.Shared.Database;
@@ -25,19 +24,63 @@ public interface IBanManager
/// <param name="severity">Severity of the resulting ban note</param>
/// <param name="reason">Reason for the ban</param>
public void CreateServerBan(NetUserId? target, string? targetUsername, NetUserId? banningAdmin, (IPAddress, int)? addressRange, ImmutableTypedHwid? hwid, uint? minutes, NoteSeverity severity, string reason);
/// <summary>
/// Gets a list of prefixed prototype IDs with the player's role bans.
/// </summary>
public HashSet<string>? GetRoleBans(NetUserId playerUserId);
/// <summary>
/// Checks if the player is currently banned from any of the listed roles.
/// </summary>
/// <param name="player">The player.</param>
/// <param name="antags">A list of valid antag prototype IDs.</param>
/// <returns>Returns True if an active role ban is found for this player for any of the listed roles.</returns>
public bool IsRoleBanned(ICommonSession player, List<ProtoId<AntagPrototype>> antags);
/// <summary>
/// Checks if the player is currently banned from any of the listed roles.
/// </summary>
/// <param name="player">The player.</param>
/// <param name="jobs">A list of valid job prototype IDs.</param>
/// <returns>Returns True if an active role ban is found for this player for any of the listed roles.</returns>
public bool IsRoleBanned(ICommonSession player, List<ProtoId<JobPrototype>> jobs);
/// <summary>
/// Gets a list of prototype IDs with the player's job bans.
/// </summary>
public HashSet<ProtoId<JobPrototype>>? GetJobBans(NetUserId playerUserId);
/// <summary>
/// Gets a list of prototype IDs with the player's antag bans.
/// </summary>
public HashSet<ProtoId<AntagPrototype>>? GetAntagBans(NetUserId playerUserId);
/// <summary>
/// Creates a job ban for the specified target, username or GUID
/// </summary>
/// <param name="target">Target user, username or GUID, null for none</param>
/// <param name="role">Role to be banned from</param>
/// <param name="targetUsername">The username of the target, if known</param>
/// <param name="banningAdmin">The responsible admin for the ban</param>
/// <param name="addressRange">The range of IPs that are to be banned, if known</param>
/// <param name="hwid">The HWID to be banned, if known</param>
/// <param name="role">The role ID to be banned from. Either an AntagPrototype or a JobPrototype</param>
/// <param name="minutes">Number of minutes to ban for. 0 and null mean permanent</param>
/// <param name="severity">Severity of the resulting ban note</param>
/// <param name="reason">Reason for the ban</param>
/// <param name="minutes">Number of minutes to ban for. 0 and null mean permanent</param>
/// <param name="timeOfBan">Time when the ban was applied, used for grouping role bans</param>
public void CreateRoleBan(NetUserId? target, string? targetUsername, NetUserId? banningAdmin, (IPAddress, int)? addressRange, ImmutableTypedHwid? hwid, string role, uint? minutes, NoteSeverity severity, string reason, DateTimeOffset timeOfBan);
public void CreateRoleBan<T>(
NetUserId? target,
string? targetUsername,
NetUserId? banningAdmin,
(IPAddress, int)? addressRange,
ImmutableTypedHwid? hwid,
ProtoId<T> role,
uint? minutes,
NoteSeverity severity,
string reason,
DateTimeOffset timeOfBan
) where T : class, IPrototype;
/// <summary>
/// Pardons a role ban for the specified target, username or GUID