using System.Net.Sockets;
using Content.Client.Administration.UI.CustomControls;
using Content.Shared.Administration;
+using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.Roles;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
// This is less efficient than just holding a reference to the root control and enumerating children, but you
// have to know how the controls are nested, which makes the code more complicated.
private readonly List<CheckBox> _roleCheckboxes = new();
+ private readonly ISawmill _banpanelSawmill;
[Dependency] private readonly IGameTiming _gameTiming = default!;
+ [Dependency] private readonly IConfigurationManager _cfg = default!;
+ [Dependency] private readonly ILogManager _logManager = default!;
private enum TabNumbers
{
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
+ _banpanelSawmill = _logManager.GetSawmill("admin.banpanel");
PlayerList.OnSelectionChanged += OnPlayerSelectionChanged;
PlayerNameLine.OnFocusExit += _ => OnPlayerNameChanged();
PlayerCheckbox.OnPressed += _ =>
};
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
+ IpCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanIpBanDefault);
+ HwidCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanHwidBanDefault);
+ LastConnCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanUseLastDetails);
+ EraseCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanErasePlayer);
+
SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-none"), (int) NoteSeverity.None);
SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-low"), (int) NoteSeverity.Minor);
SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-medium"), (int) NoteSeverity.Medium);
c.Pressed = args.Pressed;
}
}
+
+ if (args.Pressed)
+ {
+ if (!Enum.TryParse(_cfg.GetCVar(CCVars.DepartmentBanDefaultSeverity), true, out NoteSeverity newSeverity))
+ {
+ _banpanelSawmill
+ .Warning("Departmental role ban severity could not be parsed from config!");
+ return;
+ }
+ SeverityOption.SelectId((int) newSeverity);
+ }
+ else
+ {
+ foreach (var childContainer in RolesContainer.Children)
+ {
+ if (childContainer is Container)
+ {
+ foreach (var child in childContainer.Children)
+ {
+ if (child is CheckBox { Pressed: true })
+ return;
+ }
+ }
+ }
+
+ if (!Enum.TryParse(_cfg.GetCVar(CCVars.RoleBanDefaultSeverity), true, out NoteSeverity newSeverity))
+ {
+ _banpanelSawmill
+ .Warning("Role ban severity could not be parsed from config!");
+ return;
+ }
+ SeverityOption.SelectId((int) newSeverity);
+ }
};
outerContainer.AddChild(innerContainer);
foreach (var role in roleList)
{
TypeOption.ModulateSelfOverride = null;
Tabs.SetTabVisible((int) TabNumbers.Roles, TypeOption.SelectedId == (int) Types.Role);
+ NoteSeverity? newSeverity = null;
+ switch (TypeOption.SelectedId)
+ {
+ case (int)Types.Server:
+ if (Enum.TryParse(_cfg.GetCVar(CCVars.ServerBanDefaultSeverity), true, out NoteSeverity serverSeverity))
+ newSeverity = serverSeverity;
+ else
+ {
+ _banpanelSawmill
+ .Warning("Server ban severity could not be parsed from config!");
+ }
+
+ break;
+ case (int) Types.Role:
+
+ if (Enum.TryParse(_cfg.GetCVar(CCVars.RoleBanDefaultSeverity), true, out NoteSeverity roleSeverity))
+ {
+ newSeverity = roleSeverity;
+ }
+ else
+ {
+ _banpanelSawmill
+ .Warning("Role ban severity could not be parsed from config!");
+ }
+ break;
+ }
+
+ if (newSeverity != null)
+ SeverityOption.SelectId((int) newSeverity.Value);
}
private void UpdateSubmitEnabled()
/// Default severity for role bans
/// </summary>
public static readonly CVarDef<string> RoleBanDefaultSeverity =
- CVarDef.Create("admin.role_ban_default_severity", "medium", CVar.ARCHIVE | CVar.SERVER);
+ CVarDef.Create("admin.role_ban_default_severity", "medium", CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// Default severity for department bans
/// </summary>
public static readonly CVarDef<string> DepartmentBanDefaultSeverity =
- CVarDef.Create("admin.department_ban_default_severity", "medium", CVar.ARCHIVE | CVar.SERVER);
+ CVarDef.Create("admin.department_ban_default_severity", "medium", CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// Default severity for server bans
/// </summary>
public static readonly CVarDef<string> ServerBanDefaultSeverity =
- CVarDef.Create("admin.server_ban_default_severity", "High", CVar.ARCHIVE | CVar.SERVER);
+ CVarDef.Create("admin.server_ban_default_severity", "High", CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
+
+ /// <summary>
+ /// Whether a server ban will ban the player's ip by default.
+ /// </summary>
+ public static readonly CVarDef<bool> ServerBanIpBanDefault =
+ CVarDef.Create("admin.server_ban_ip_ban_default", true, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
+
+ /// <summary>
+ /// Whether a server ban will ban the player's hardware id by default.
+ /// </summary>
+ public static readonly CVarDef<bool> ServerBanHwidBanDefault =
+ CVarDef.Create("admin.server_ban_hwid_ban_default", true, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
+
+ /// <summary>
+ /// Whether to use details from last connection for ip/hwid in the BanPanel.
+ /// </summary>
+ public static readonly CVarDef<bool> ServerBanUseLastDetails =
+ CVarDef.Create("admin.server_ban_use_last_details", true, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
+
+ /// <summary>
+ /// Whether to erase a player's chat messages and their entity from the game when banned.
+ /// </summary>
+ public static readonly CVarDef<bool> ServerBanErasePlayer =
+ CVarDef.Create("admin.server_ban_erase_player", false, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// Minimum explosion intensity to create an admin alert message. -1 to disable the alert.