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);
|
null);
|
||||||
|
|
||||||
await _db.AddServerBanAsync(banDef);
|
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
|
var adminName = banningAdmin == null
|
||||||
? Loc.GetString("system-user")
|
? Loc.GetString("system-user")
|
||||||
: (await _db.GetPlayerRecordByUserId(banningAdmin.Value))?.LastSeenUserName ?? 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());
|
.SingleOrDefaultAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetLastReadRules(NetUserId player, DateTimeOffset date)
|
public async Task SetLastReadRules(NetUserId player, DateTimeOffset? date)
|
||||||
{
|
{
|
||||||
await using var db = await GetDb();
|
await using var db = await GetDb();
|
||||||
|
|
||||||
@@ -1122,7 +1122,7 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id}
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPlayer.LastReadRules = date.UtcDateTime;
|
dbPlayer.LastReadRules = date?.UtcDateTime;
|
||||||
await db.DbContext.SaveChangesAsync();
|
await db.DbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ namespace Content.Server.Database
|
|||||||
#region Rules
|
#region Rules
|
||||||
|
|
||||||
Task<DateTimeOffset?> GetLastReadRules(NetUserId player);
|
Task<DateTimeOffset?> GetLastReadRules(NetUserId player);
|
||||||
Task SetLastReadRules(NetUserId player, DateTimeOffset time);
|
Task SetLastReadRules(NetUserId player, DateTimeOffset? time);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -830,7 +830,7 @@ namespace Content.Server.Database
|
|||||||
return RunDbCommand(() => _db.GetLastReadRules(player));
|
return RunDbCommand(() => _db.GetLastReadRules(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetLastReadRules(NetUserId player, DateTimeOffset time)
|
public Task SetLastReadRules(NetUserId player, DateTimeOffset? time)
|
||||||
{
|
{
|
||||||
DbWriteOpsMetric.Inc();
|
DbWriteOpsMetric.Inc();
|
||||||
return RunDbCommand(() => _db.SetLastReadRules(player, time));
|
return RunDbCommand(() => _db.SetLastReadRules(player, time));
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public sealed class RulesManager
|
|||||||
{
|
{
|
||||||
PopupTime = _cfg.GetCVar(CCVars.RulesWaitTime),
|
PopupTime = _cfg.GetCVar(CCVars.RulesWaitTime),
|
||||||
CoreRules = _cfg.GetCVar(CCVars.RulesFile),
|
CoreRules = _cfg.GetCVar(CCVars.RulesFile),
|
||||||
ShouldShowRules = !isLocalhost && !hasCooldown
|
ShouldShowRules = !isLocalhost && !hasCooldown,
|
||||||
};
|
};
|
||||||
_netManager.ServerSendMessage(showRulesMessage, e.Channel);
|
_netManager.ServerSendMessage(showRulesMessage, e.Channel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,12 @@ public sealed partial class CCVars
|
|||||||
public static readonly CVarDef<bool> ServerBanErasePlayer =
|
public static readonly CVarDef<bool> ServerBanErasePlayer =
|
||||||
CVarDef.Create("admin.server_ban_erase_player", false, CVar.ARCHIVE | CVar.SERVER | CVar.REPLICATED);
|
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>
|
/// <summary>
|
||||||
/// Minimum players sharing a connection required to create an alert. -1 to disable the alert.
|
/// Minimum players sharing a connection required to create an alert. -1 to disable the alert.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user