After getting banned, you now have to re-read the rules! (#33270)
* first commit * opps * Reset cooldown instead * Added ccvar * Not replicated!
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user