Make ban command properly give a ban message instead of a placeholder (#5087)
This commit is contained in:
@@ -103,13 +103,13 @@ namespace Content.Server.Administration.Commands
|
|||||||
|
|
||||||
response.Append(expires == null ?
|
response.Append(expires == null ?
|
||||||
" permanently."
|
" permanently."
|
||||||
: $" until {expires.ToString()}");
|
: $" until {expires}");
|
||||||
|
|
||||||
shell.WriteLine(response.ToString());
|
shell.WriteLine(response.ToString());
|
||||||
|
|
||||||
if (plyMgr.TryGetSessionById(targetUid, out var targetPlayer))
|
if (plyMgr.TryGetSessionById(targetUid, out var targetPlayer))
|
||||||
{
|
{
|
||||||
targetPlayer.ConnectedClient.Disconnect("You've been banned. Tough shit.");
|
targetPlayer.ConnectedClient.Disconnect(banDef.DisconnectMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,17 +73,7 @@ The ban reason is: ""{ban.Reason}""
|
|||||||
var ban = await _db.GetServerBanAsync(addr, userId, hwId);
|
var ban = await _db.GetServerBanAsync(addr, userId, hwId);
|
||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
var expires = "This is a permanent ban.";
|
e.Deny(ban.DisconnectMessage);
|
||||||
if (ban.ExpirationTime is { } expireTime)
|
|
||||||
{
|
|
||||||
var duration = expireTime - ban.BanTime;
|
|
||||||
var utc = expireTime.ToUniversalTime();
|
|
||||||
expires = $"This ban is for {duration.TotalMinutes:N0} minutes and will expire at {utc:f} UTC.";
|
|
||||||
}
|
|
||||||
var reason = $@"You, or another user of this computer or connection, are banned from playing here.
|
|
||||||
The ban reason is: ""{ban.Reason}""
|
|
||||||
{expires}";
|
|
||||||
e.Deny(reason);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,5 +52,19 @@ namespace Content.Server.Database
|
|||||||
BanningAdmin = banningAdmin;
|
BanningAdmin = banningAdmin;
|
||||||
Unban = unban;
|
Unban = unban;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DisconnectMessage
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
var expires = "This is a permanent ban.";
|
||||||
|
if (this.ExpirationTime is { } expireTime)
|
||||||
|
{
|
||||||
|
var duration = expireTime - this.BanTime;
|
||||||
|
var utc = expireTime.ToUniversalTime();
|
||||||
|
expires = $"This ban is for {duration.TotalMinutes:N0} minutes and will expire at {utc:f} UTC.";
|
||||||
|
}
|
||||||
|
return $"You, or another user of this computer or connection, are banned from playing here.\nThe ban reason is: \"{this.Reason}\"\n{expires}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user