Panic Bunker uses minutes not hours (#28805)

* Panic Bunker uses minutes not hours

* Fixing an instance of hours
This commit is contained in:
Hannah Giovanna Dawson
2024-06-09 21:45:47 +01:00
committed by GitHub
parent 50d83b9360
commit 1bb9d9451f
14 changed files with 56 additions and 53 deletions

View File

@@ -2,5 +2,5 @@
xmlns="https://spacestation14.io" xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.Administration.UI.Tabs.BabyJailTab" xmlns:controls="clr-namespace:Content.Client.Administration.UI.Tabs.BabyJailTab"
Title="{Loc admin-ui-baby-jail-window-title}"> Title="{Loc admin-ui-baby-jail-window-title}">
<Label Name="MessageLabel" Access="Public" Text="{Loc admin-ui-baby-jail-is-enabled}" /> <RichTextLabel Name="MessageLabel" Access="Public" />
</controls:BabyJailStatusWindow> </controls:BabyJailStatusWindow>

View File

@@ -1,4 +1,6 @@
using Robust.Client.AutoGenerated; using Content.Client.Message;
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
@@ -9,10 +11,11 @@ namespace Content.Client.Administration.UI.Tabs.BabyJailTab;
*/ */
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class BabyJailStatusWindow : DefaultWindow public sealed partial class BabyJailStatusWindow : FancyWindow
{ {
public BabyJailStatusWindow() public BabyJailStatusWindow()
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
MessageLabel.SetMarkup(Loc.GetString("admin-ui-baby-jail-is-enabled"));
} }
} }

View File

@@ -31,12 +31,12 @@
<BoxContainer Orientation="Horizontal" Margin="2"> <BoxContainer Orientation="Horizontal" Margin="2">
<Label Text="{Loc admin-ui-panic-bunker-min-account-age}" MinWidth="175" /> <Label Text="{Loc admin-ui-panic-bunker-min-account-age}" MinWidth="175" />
<LineEdit Name="MinAccountAge" MinWidth="50" Margin="0 0 5 0" /> <LineEdit Name="MinAccountAge" MinWidth="50" Margin="0 0 5 0" />
<Label Text="{Loc generic-hours}" /> <Label Text="{Loc generic-minutes}" />
</BoxContainer> </BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="2"> <BoxContainer Orientation="Horizontal" Margin="2">
<Label Text="{Loc admin-ui-panic-bunker-min-overall-hours}" MinWidth="175" /> <Label Text="{Loc admin-ui-panic-bunker-min-overall-minutes}" MinWidth="175" />
<LineEdit Name="MinOverallHours" MinWidth="50" Margin="0 0 5 0" /> <LineEdit Name="MinOverallMinutes" MinWidth="50" Margin="0 0 5 0" />
<Label Text="{Loc generic-hours}" /> <Label Text="{Loc generic-minutes}" />
</BoxContainer> </BoxContainer>
</BoxContainer> </BoxContainer>
</BoxContainer> </BoxContainer>

View File

@@ -12,7 +12,7 @@ public sealed partial class PanicBunkerTab : Control
[Dependency] private readonly IConsoleHost _console = default!; [Dependency] private readonly IConsoleHost _console = default!;
private string _minAccountAge; private string _minAccountAge;
private string _minOverallHours; private string _minOverallMinutes;
public PanicBunkerTab() public PanicBunkerTab()
{ {
@@ -25,9 +25,9 @@ public sealed partial class PanicBunkerTab : Control
MinAccountAge.OnFocusExit += args => SendMinAccountAge(args.Text); MinAccountAge.OnFocusExit += args => SendMinAccountAge(args.Text);
_minAccountAge = MinAccountAge.Text; _minAccountAge = MinAccountAge.Text;
MinOverallHours.OnTextEntered += args => SendMinOverallHours(args.Text); MinOverallMinutes.OnTextEntered += args => SendMinOverallMinutes(args.Text);
MinOverallHours.OnFocusExit += args => SendMinOverallHours(args.Text); MinOverallMinutes.OnFocusExit += args => SendMinOverallMinutes(args.Text);
_minOverallHours = MinOverallHours.Text; _minOverallMinutes = MinOverallMinutes.Text;
} }
private void SendMinAccountAge(string text) private void SendMinAccountAge(string text)
@@ -42,16 +42,16 @@ public sealed partial class PanicBunkerTab : Control
_console.ExecuteCommand($"panicbunker_min_account_age {minutes}"); _console.ExecuteCommand($"panicbunker_min_account_age {minutes}");
} }
private void SendMinOverallHours(string text) private void SendMinOverallMinutes(string text)
{ {
if (string.IsNullOrWhiteSpace(text) || if (string.IsNullOrWhiteSpace(text) ||
text == _minOverallHours || text == _minOverallMinutes ||
!int.TryParse(text, out var hours)) !int.TryParse(text, out var minutes))
{ {
return; return;
} }
_console.ExecuteCommand($"panicbunker_min_overall_hours {hours}"); _console.ExecuteCommand($"panicbunker_min_overall_minutes {minutes}");
} }
public void UpdateStatus(PanicBunkerStatus status) public void UpdateStatus(PanicBunkerStatus status)
@@ -68,10 +68,10 @@ public sealed partial class PanicBunkerTab : Control
CountDeadminnedButton.Pressed = status.CountDeadminnedAdmins; CountDeadminnedButton.Pressed = status.CountDeadminnedAdmins;
ShowReasonButton.Pressed = status.ShowReason; ShowReasonButton.Pressed = status.ShowReason;
MinAccountAge.Text = status.MinAccountAgeHours.ToString(); MinAccountAge.Text = status.MinAccountAgeMinutes.ToString();
_minAccountAge = MinAccountAge.Text; _minAccountAge = MinAccountAge.Text;
MinOverallHours.Text = status.MinOverallHours.ToString(); MinOverallMinutes.Text = status.MinOverallMinutes.ToString();
_minOverallHours = MinOverallHours.Text; _minOverallMinutes = MinOverallMinutes.Text;
} }
} }

View File

@@ -139,7 +139,7 @@ public sealed class PanicBunkerMinAccountAgeCommand : LocalizedCommands
if (args.Length == 0) if (args.Length == 0)
{ {
var current = _cfg.GetCVar(CCVars.PanicBunkerMinAccountAge); var current = _cfg.GetCVar(CCVars.PanicBunkerMinAccountAge);
shell.WriteLine(Loc.GetString("panicbunker-command-min-account-age-is", ("hours", current / 60))); shell.WriteLine(Loc.GetString("panicbunker-command-min-account-age-is", ("minutes", current)));
} }
if (args.Length > 1) if (args.Length > 1)
@@ -148,30 +148,30 @@ public sealed class PanicBunkerMinAccountAgeCommand : LocalizedCommands
return; return;
} }
if (!int.TryParse(args[0], out var hours)) if (!int.TryParse(args[0], out var minutes))
{ {
shell.WriteError(Loc.GetString("shell-argument-must-be-number")); shell.WriteError(Loc.GetString("shell-argument-must-be-number"));
return; return;
} }
_cfg.SetCVar(CCVars.PanicBunkerMinAccountAge, hours * 60); _cfg.SetCVar(CCVars.PanicBunkerMinAccountAge, minutes);
shell.WriteLine(Loc.GetString("panicbunker-command-min-account-age-set", ("hours", hours))); shell.WriteLine(Loc.GetString("panicbunker-command-min-account-age-set", ("minutes", minutes)));
} }
} }
[AdminCommand(AdminFlags.Server)] [AdminCommand(AdminFlags.Server)]
public sealed class PanicBunkerMinOverallHoursCommand : LocalizedCommands public sealed class PanicBunkerMinOverallMinutesCommand : LocalizedCommands
{ {
[Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConfigurationManager _cfg = default!;
public override string Command => "panicbunker_min_overall_hours"; public override string Command => "panicbunker_min_overall_minutes";
public override void Execute(IConsoleShell shell, string argStr, string[] args) public override void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
{ {
var current = _cfg.GetCVar(CCVars.PanicBunkerMinOverallHours); var current = _cfg.GetCVar(CCVars.PanicBunkerMinOverallMinutes);
shell.WriteLine(Loc.GetString("panicbunker-command-min-overall-hours-is", ("minutes", current))); shell.WriteLine(Loc.GetString("panicbunker-command-min-overall-minutes-is", ("minutes", current)));
} }
if (args.Length > 1) if (args.Length > 1)
@@ -180,13 +180,13 @@ public sealed class PanicBunkerMinOverallHoursCommand : LocalizedCommands
return; return;
} }
if (!int.TryParse(args[0], out var hours)) if (!int.TryParse(args[0], out var minutes))
{ {
shell.WriteError(Loc.GetString("shell-argument-must-be-number")); shell.WriteError(Loc.GetString("shell-argument-must-be-number"));
return; return;
} }
_cfg.SetCVar(CCVars.PanicBunkerMinOverallHours, hours); _cfg.SetCVar(CCVars.PanicBunkerMinOverallMinutes, minutes);
shell.WriteLine(Loc.GetString("panicbunker-command-overall-hours-age-set", ("hours", hours))); shell.WriteLine(Loc.GetString("panicbunker-command-overall-minutes-age-set", ("minutes", minutes)));
} }
} }

View File

@@ -41,7 +41,7 @@ public sealed partial class ServerApi : IPostInjectInit
CCVars.PanicBunkerCountDeadminnedAdmins.Name, CCVars.PanicBunkerCountDeadminnedAdmins.Name,
CCVars.PanicBunkerShowReason.Name, CCVars.PanicBunkerShowReason.Name,
CCVars.PanicBunkerMinAccountAge.Name, CCVars.PanicBunkerMinAccountAge.Name,
CCVars.PanicBunkerMinOverallHours.Name, CCVars.PanicBunkerMinOverallMinutes.Name,
CCVars.PanicBunkerCustomReason.Name, CCVars.PanicBunkerCustomReason.Name,
]; ];

View File

@@ -78,7 +78,7 @@ namespace Content.Server.Administration.Systems
Subs.CVar(_config, CCVars.PanicBunkerCountDeadminnedAdmins, OnPanicBunkerCountDeadminnedAdminsChanged, true); Subs.CVar(_config, CCVars.PanicBunkerCountDeadminnedAdmins, OnPanicBunkerCountDeadminnedAdminsChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerShowReason, OnPanicBunkerShowReasonChanged, true); Subs.CVar(_config, CCVars.PanicBunkerShowReason, OnPanicBunkerShowReasonChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerMinAccountAge, OnPanicBunkerMinAccountAgeChanged, true); Subs.CVar(_config, CCVars.PanicBunkerMinAccountAge, OnPanicBunkerMinAccountAgeChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerMinOverallHours, OnPanicBunkerMinOverallHoursChanged, true); Subs.CVar(_config, CCVars.PanicBunkerMinOverallMinutes, OnPanicBunkerMinOverallMinutesChanged, true);
/* /*
* TODO: Remove baby jail code once a more mature gateway process is established. This code is only being issued as a stopgap to help with potential tiding in the immediate future. * TODO: Remove baby jail code once a more mature gateway process is established. This code is only being issued as a stopgap to help with potential tiding in the immediate future.
@@ -304,7 +304,7 @@ namespace Content.Server.Administration.Systems
private void OnPanicBunkerMinAccountAgeChanged(int minutes) private void OnPanicBunkerMinAccountAgeChanged(int minutes)
{ {
PanicBunker.MinAccountAgeHours = minutes / 60; PanicBunker.MinAccountAgeMinutes = minutes;
SendPanicBunkerStatusAll(); SendPanicBunkerStatusAll();
} }
@@ -314,9 +314,9 @@ namespace Content.Server.Administration.Systems
SendBabyJailStatusAll(); SendBabyJailStatusAll();
} }
private void OnPanicBunkerMinOverallHoursChanged(int hours) private void OnPanicBunkerMinOverallMinutesChanged(int minutes)
{ {
PanicBunker.MinOverallHours = hours; PanicBunker.MinOverallMinutes = minutes;
SendPanicBunkerStatusAll(); SendPanicBunkerStatusAll();
} }

View File

@@ -186,9 +186,9 @@ namespace Content.Server.Connection
("reason", Loc.GetString("panic-bunker-account-reason-account", ("minutes", minMinutesAge)))), null); ("reason", Loc.GetString("panic-bunker-account-reason-account", ("minutes", minMinutesAge)))), null);
} }
var minOverallHours = _cfg.GetCVar(CCVars.PanicBunkerMinOverallHours); var minOverallMinutes = _cfg.GetCVar(CCVars.PanicBunkerMinOverallMinutes);
var overallTime = ( await _db.GetPlayTimes(e.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall); var overallTime = ( await _db.GetPlayTimes(e.UserId)).Find(p => p.Tracker == PlayTimeTrackingShared.TrackerOverall);
var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalHours > minOverallHours; var haveMinOverallTime = overallTime != null && overallTime.TimeSpent.TotalMinutes > minOverallMinutes;
// Use the custom reason if it exists & they don't have the minimum time // Use the custom reason if it exists & they don't have the minimum time
if (customReason != string.Empty && !haveMinOverallTime && !bypassAllowed) if (customReason != string.Empty && !haveMinOverallTime && !bypassAllowed)
@@ -200,7 +200,7 @@ namespace Content.Server.Connection
{ {
return (ConnectionDenyReason.Panic, return (ConnectionDenyReason.Panic,
Loc.GetString("panic-bunker-account-denied-reason", Loc.GetString("panic-bunker-account-denied-reason",
("reason", Loc.GetString("panic-bunker-account-reason-overall", ("hours", minOverallHours)))), null); ("reason", Loc.GetString("panic-bunker-account-reason-overall", ("minutes", minOverallMinutes)))), null);
} }
if (!validAccountAge || !haveMinOverallTime && !bypassAllowed) if (!validAccountAge || !haveMinOverallTime && !bypassAllowed)

View File

@@ -10,8 +10,8 @@ public sealed class PanicBunkerStatus
public bool EnableWithoutAdmins; public bool EnableWithoutAdmins;
public bool CountDeadminnedAdmins; public bool CountDeadminnedAdmins;
public bool ShowReason; public bool ShowReason;
public int MinAccountAgeHours; public int MinAccountAgeMinutes;
public int MinOverallHours; public int MinOverallMinutes;
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -304,8 +304,8 @@ namespace Content.Shared.CCVar
/// <summary> /// <summary>
/// Minimal overall played time. /// Minimal overall played time.
/// </summary> /// </summary>
public static readonly CVarDef<int> PanicBunkerMinOverallHours = public static readonly CVarDef<int> PanicBunkerMinOverallMinutes =
CVarDef.Create("game.panic_bunker.min_overall_hours", 10, CVar.SERVERONLY); CVarDef.Create("game.panic_bunker.min_overall_minutes", 600, CVar.SERVERONLY);
/// <summary> /// <summary>
/// A custom message that will be used for connections denied to the panic bunker /// A custom message that will be used for connections denied to the panic bunker

View File

@@ -23,12 +23,12 @@ cmd-panicbunker_show_reason-help = Usage: panicbunker_show_reason
panicbunker-command-show-reason-enabled = The panic bunker will now show a reason to users it blocks from connecting. panicbunker-command-show-reason-enabled = The panic bunker will now show a reason to users it blocks from connecting.
panicbunker-command-show-reason-disabled = The panic bunker will no longer show a reason to users it blocks from connecting. panicbunker-command-show-reason-disabled = The panic bunker will no longer show a reason to users it blocks from connecting.
cmd-panicbunker_min_account_age-desc = Gets or sets the minimum account age in hours that an account must have to be allowed to connect with the panic bunker enabled. cmd-panicbunker_min_account_age-desc = Gets or sets the minimum account age in minutes that an account must have to be allowed to connect with the panic bunker enabled.
cmd-panicbunker_min_account_age-help = Usage: panicbunker_min_account_age <hours> cmd-panicbunker_min_account_age-help = Usage: panicbunker_min_account_age <minutes>
panicbunker-command-min-account-age-is = The minimum account age for the panic bunker is {$hours} hours. panicbunker-command-min-account-age-is = The minimum account age for the panic bunker is {$minutes} minutes.
panicbunker-command-min-account-age-set = Set the minimum account age for the panic bunker to {$hours} hours. panicbunker-command-min-account-age-set = Set the minimum account age for the panic bunker to {$minutes} minutes.
cmd-panicbunker_min_overall_hours-desc = Gets or sets the minimum overall playtime in hours that an account must have to be allowed to connect with the panic bunker enabled. cmd-panicbunker_min_overall_minutes-desc = Gets or sets the minimum overall playtime in minutes that an account must have to be allowed to connect with the panic bunker enabled.
cmd-panicbunker_min_overall_hours-help = Usage: panicbunker_min_overall_hours <hours> cmd-panicbunker_min_overall_minutes-help = Usage: panicbunker_min_overall_minutes <minutes>
panicbunker-command-min-overall-hours-is = The minimum overall playtime for the panic bunker is {$hours} hours. panicbunker-command-min-overall-minutes-is = The minimum overall playtime for the panic bunker is {$minutes} minutes.
panicbunker-command-min-overall-hours-set = Set the minimum overall playtime for the panic bunker to {$hours} hours. panicbunker-command-min-overall-minutes-set = Set the minimum overall playtime for the panic bunker to {$minutes} minutes.

View File

@@ -10,7 +10,7 @@ admin-ui-baby-jail-show-reason-tooltip = Show the user why they were blocked fro
admin-ui-baby-jail-max-account-age = Max. Account Age admin-ui-baby-jail-max-account-age = Max. Account Age
admin-ui-baby-jail-max-overall-minutes = Max. Overall Playtime admin-ui-baby-jail-max-overall-minutes = Max. Overall Playtime
admin-ui-baby-jail-is-enabled = The baby jail is currently enabled. admin-ui-baby-jail-is-enabled = [font size=20][bold]The baby jail is currently enabled.[/bold][/font]
admin-ui-baby-jail-enabled-admin-alert = The baby jail has been enabled. admin-ui-baby-jail-enabled-admin-alert = The baby jail has been enabled.
admin-ui-baby-jail-disabled-admin-alert = The baby jail has been disabled. admin-ui-baby-jail-disabled-admin-alert = The baby jail has been disabled.

View File

@@ -16,7 +16,7 @@ admin-ui-panic-bunker-show-reason = Show Reason
admin-ui-panic-bunker-show-reason-tooltip = Show the user why they were blocked from connecting by the panic bunker. admin-ui-panic-bunker-show-reason-tooltip = Show the user why they were blocked from connecting by the panic bunker.
admin-ui-panic-bunker-min-account-age = Min. Account Age admin-ui-panic-bunker-min-account-age = Min. Account Age
admin-ui-panic-bunker-min-overall-hours = Min. Overall Playtime admin-ui-panic-bunker-min-overall-minutes = Min. Overall Playtime
admin-ui-panic-bunker-is-enabled = The panic bunker is currently enabled. admin-ui-panic-bunker-is-enabled = The panic bunker is currently enabled.

View File

@@ -38,10 +38,10 @@ soft-player-cap-full = The server is full!
panic-bunker-account-denied = This server is in panic bunker mode, often enabled as a precaution against raids. New connections by accounts not meeting certain requirements are temporarily not accepted. Try again later panic-bunker-account-denied = This server is in panic bunker mode, often enabled as a precaution against raids. New connections by accounts not meeting certain requirements are temporarily not accepted. Try again later
panic-bunker-account-denied-reason = This server is in panic bunker mode, often enabled as a precaution against raids. New connections by accounts not meeting certain requirements are temporarily not accepted. Try again later. Reason: "{$reason}" panic-bunker-account-denied-reason = This server is in panic bunker mode, often enabled as a precaution against raids. New connections by accounts not meeting certain requirements are temporarily not accepted. Try again later. Reason: "{$reason}"
panic-bunker-account-reason-account = Your Space Station 14 account is too new. It must be older than {$minutes} minutes panic-bunker-account-reason-account = Your Space Station 14 account is too new. It must be older than {$minutes} minutes
panic-bunker-account-reason-overall = Your overall playtime on the server must be greater than {$hours} hours panic-bunker-account-reason-overall = Your overall playtime on the server must be greater than {$minutes} $minutes
baby-jail-account-denied = This server is a newbie server, intended for new players and those who want to help them. New connections by accounts that are too old or are not on a whitelist are not accepted. Check out some other servers and see everything Space Station 14 has to offer. Have fun! baby-jail-account-denied = This server is a newbie server, intended for new players and those who want to help them. New connections by accounts that are too old or are not on a whitelist are not accepted. Check out some other servers and see everything Space Station 14 has to offer. Have fun!
baby-jail-account-denied-reason = This server is a newbie server, intended for new players and those who want to help them. New connections by accounts that are too old or are not on a whitelist are not accepted. Check out some other servers and see everything Space Station 14 has to offer. Have fun! Reason: "{$reason}" baby-jail-account-denied-reason = This server is a newbie server, intended for new players and those who want to help them. New connections by accounts that are too old or are not on a whitelist are not accepted. Check out some other servers and see everything Space Station 14 has to offer. Have fun! Reason: "{$reason}"
baby-jail-account-reason-account = Your Space Station 14 account is too old. It must be younger than {$minutes} minutes baby-jail-account-reason-account = Your Space Station 14 account is too old. It must be younger than {$minutes} minutes
baby-jail-account-reason-overall = Your overall playtime on the server must be younger than {$hours} hours baby-jail-account-reason-overall = Your overall playtime on the server must be younger than {$minutes} $minutes