enhancement for issue #63
This commit is contained in:
parent
b4e3e8526a
commit
9c4d23f0b4
@ -97,20 +97,27 @@ namespace IW4MAdmin
|
||||
|
||||
override public async Task OnClientDisconnected(EFClient client)
|
||||
{
|
||||
Logger.WriteInfo($"Client {client} [{client.State.ToString().ToLower()}] disconnecting...");
|
||||
await client.OnDisconnect();
|
||||
Clients[client.ClientNumber] = null;
|
||||
#if DEBUG == true
|
||||
Logger.WriteDebug($"End PreDisconnect for {client}");
|
||||
#endif
|
||||
var e = new GameEvent()
|
||||
if (client.ClientNumber >= 0)
|
||||
{
|
||||
Origin = client,
|
||||
Owner = this,
|
||||
Type = GameEvent.EventType.Disconnect
|
||||
};
|
||||
#endif
|
||||
Logger.WriteInfo($"Client {client} [{client.State.ToString().ToLower()}] disconnecting...");
|
||||
await client.OnDisconnect();
|
||||
Clients[client.ClientNumber] = null;
|
||||
#if DEBUG == true
|
||||
Logger.WriteDebug($"End PreDisconnect for {client}");
|
||||
#endif
|
||||
var e = new GameEvent()
|
||||
{
|
||||
Origin = client,
|
||||
Owner = this,
|
||||
Type = GameEvent.EventType.Disconnect
|
||||
};
|
||||
|
||||
Manager.GetEventHandler().AddEvent(e);
|
||||
Manager.GetEventHandler().AddEvent(e);
|
||||
#if DEBUG == true
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override async Task ExecuteEvent(GameEvent E)
|
||||
|
@ -19,5 +19,6 @@ namespace SharedLibraryCore.Dtos
|
||||
public string Type { get; set; }
|
||||
public string TimePunished { get; set; }
|
||||
public string TimeRemaining { get; set; }
|
||||
public bool Expired { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Services
|
||||
@ -33,6 +32,7 @@ namespace SharedLibraryCore.Services
|
||||
};
|
||||
break;
|
||||
case GameEvent.EventType.Command:
|
||||
// this prevents passwords/tokens being logged into the database in plain text
|
||||
if (e.Extra is Command cmd)
|
||||
{
|
||||
if (cmd.Name == "login" || cmd.Name == "setpassword")
|
||||
|
@ -197,7 +197,8 @@ namespace SharedLibraryCore.Services
|
||||
Offense = penalty.Offense,
|
||||
Type = penalty.Type.ToString(),
|
||||
TimeRemaining = penalty.Expires.HasValue ? (now > penalty.Expires ? "" : penalty.Expires.ToString()) : DateTime.MaxValue.ToString(),
|
||||
AutomatedOffense = penalty.AutomatedOffense
|
||||
AutomatedOffense = penalty.AutomatedOffense,
|
||||
Expired = penalty.Expires.HasValue && penalty.Expires <= DateTime.UtcNow
|
||||
},
|
||||
When = penalty.When,
|
||||
Sensitive = penalty.Type == Penalty.PenaltyType.Flag
|
||||
@ -216,6 +217,11 @@ namespace SharedLibraryCore.Services
|
||||
if (pi.TimeRemaining?.Length > 0)
|
||||
{
|
||||
pi.TimeRemaining = (DateTime.Parse(((PenaltyInfo)p.Value).TimeRemaining) - now).TimeSpanText();
|
||||
|
||||
if (!pi.Expired)
|
||||
{
|
||||
pi.TimeRemaining = $"{pi.TimeRemaining} {Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_PENALTY_TEMPLATE_REMAINING"]}";
|
||||
}
|
||||
}
|
||||
});
|
||||
return list;
|
||||
|
@ -95,6 +95,18 @@ namespace WebfrontCore.Controllers
|
||||
administeredPenaltiesMeta.ForEach(p => p.Value.Offense = p.Value.AutomatedOffense ?? p.Value.Offense);
|
||||
}
|
||||
|
||||
var currentPenalty = activePenalties.FirstOrDefault();
|
||||
|
||||
if (currentPenalty != null && currentPenalty.Type == SharedLibraryCore.Objects.Penalty.PenaltyType.TempBan)
|
||||
{
|
||||
clientDto.Meta.Add(new ProfileMeta()
|
||||
{
|
||||
Key = Localization["WEBFRONT_CLIENT_META_REMAINING_BAN"],
|
||||
Value = ((currentPenalty.Expires - DateTime.UtcNow) ?? new TimeSpan()).TimeSpanText(),
|
||||
When = currentPenalty.When
|
||||
});
|
||||
}
|
||||
|
||||
clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive));
|
||||
clientDto.Meta.AddRange(Authorized ? penaltyMeta : penaltyMeta.Where(m => !m.Sensitive));
|
||||
clientDto.Meta.AddRange(Authorized ? administeredPenaltiesMeta : administeredPenaltiesMeta.Where(m => !m.Sensitive));
|
||||
|
@ -209,7 +209,7 @@ function loadMeta(meta) {
|
||||
if (meta.class.includes("Penalty")) {
|
||||
if (meta.value.punisherId !== clientInfo.clientId) {
|
||||
const timeRemaining = meta.value.type === 'TempBan' && meta.value.timeRemaining.length > 0 ?
|
||||
`(${meta.value.timeRemaining} remaining)` :
|
||||
`(${meta.value.timeRemaining})` :
|
||||
'';
|
||||
eventString = `<div><span class="penalties-color-${meta.value.type.toLowerCase()}">${penaltyToName(meta.value.type)}</span> by <span class="text-highlight"> <a class="link-inverse" href="${meta.value.punisherId}">${meta.value.punisherName}</a></span > for <span style="color: white; " class="automated-penalty-info-detailed" data-clientid="${meta.value.offenderId}">${meta.value.offense}</span><span class="text-muted"> ${timeRemaining}</span></div>`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user