]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
After getting banned, you now have to re-read the rules! (#33270)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Thu, 30 Jan 2025 12:09:31 +0000 (04:09 -0800)
committerGitHub <noreply@github.com>
Thu, 30 Jan 2025 12:09:31 +0000 (13:09 +0100)
* first commit

* opps

* Reset cooldown instead

* Added ccvar

* Not replicated!

Content.Server/Administration/Managers/BanManager.cs
Content.Server/Database/ServerDbBase.cs
Content.Server/Database/ServerDbManager.cs
Content.Server/Info/RulesManager.cs
Content.Shared/CCVar/CCVars.Admin.cs

index c65059f55ddc0bd666a3134f32363e2c6749e9c4..2d76c434e9df0aebac2633530dd4f407c2f41760 100644 (file)
@@ -165,6 +165,8 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
             null);
 
         await _db.AddServerBanAsync(banDef);
+        if (_cfg.GetCVar(CCVars.ServerBanResetLastReadRules) && target != null)
+            await _db.SetLastReadRules(target.Value, null); // Reset their last read rules. They probably need a refresher!
         var adminName = banningAdmin == null
             ? Loc.GetString("system-user")
             : (await _db.GetPlayerRecordByUserId(banningAdmin.Value))?.LastSeenUserName ?? Loc.GetString("system-user");
index b75870ac0e64f3adae21e28262c7305ee7d7df4e..ccbaf276cd4d9c612c1676546e39d73924f4cede 100644 (file)
@@ -1112,7 +1112,7 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id}
                 .SingleOrDefaultAsync());
         }
 
-        public async Task SetLastReadRules(NetUserId player, DateTimeOffset date)
+        public async Task SetLastReadRules(NetUserId player, DateTimeOffset? date)
         {
             await using var db = await GetDb();
 
@@ -1122,7 +1122,7 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id}
                 return;
             }
 
-            dbPlayer.LastReadRules = date.UtcDateTime;
+            dbPlayer.LastReadRules = date?.UtcDateTime;
             await db.DbContext.SaveChangesAsync();
         }
 
index 5ddb3a590cbe49cb6856ed76fad45fdd31ecac7b..e3cfb66c7f7a8133f6f738c3684324866f9f29e4 100644 (file)
@@ -282,7 +282,7 @@ namespace Content.Server.Database
         #region Rules
 
         Task<DateTimeOffset?> GetLastReadRules(NetUserId player);
-        Task SetLastReadRules(NetUserId player, DateTimeOffset time);
+        Task SetLastReadRules(NetUserId player, DateTimeOffset? time);
 
         #endregion
 
@@ -830,7 +830,7 @@ namespace Content.Server.Database
             return RunDbCommand(() => _db.GetLastReadRules(player));
         }
 
-        public Task SetLastReadRules(NetUserId player, DateTimeOffset time)
+        public Task SetLastReadRules(NetUserId player, DateTimeOffset? time)
         {
             DbWriteOpsMetric.Inc();
             return RunDbCommand(() => _db.SetLastReadRules(player, time));
index f4d9e57bd4ddbd3d81e444dddbcb678029cb53b6..224d7f7d9af39096b580d167adddfddfa129a50a 100644 (file)
@@ -34,7 +34,7 @@ public sealed class RulesManager
         {
             PopupTime = _cfg.GetCVar(CCVars.RulesWaitTime),
             CoreRules = _cfg.GetCVar(CCVars.RulesFile),
-            ShouldShowRules = !isLocalhost && !hasCooldown
+            ShouldShowRules = !isLocalhost && !hasCooldown,
         };
         _netManager.ServerSendMessage(showRulesMessage, e.Channel);
     }
index bbce533ed1bb3797ac3dce7a2806cf172c6d6950..f05eb3376ea70ddc354bd4207885adf74b0f9d95 100644 (file)
@@ -89,6 +89,12 @@ public sealed partial class CCVars
     public static readonly CVarDef<bool> ServerBanErasePlayer =
         CVarDef.Create("admin.server_ban_erase_player", false, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
 
+    /// <summary>
+    ///     If true, will reset the last time the player has read the rules. This will mean on their next login they will be shown the rules again.
+    /// </summary>
+    public static readonly CVarDef<bool> ServerBanResetLastReadRules =
+        CVarDef.Create("admin.server_ban_reset_last_read_rules", true, CVar.ARCHIVE | CVar.SERVER);
+
     /// <summary>
     ///     Minimum players sharing a connection required to create an alert. -1 to disable the alert.
     /// </summary>