diff --git a/Admin/Server.cs b/Admin/Server.cs index 5fa96ba50..ab489fd33 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -70,12 +70,16 @@ namespace IW4MAdmin if (!aliasExists) { - Logger.WriteDebug($"Client {polledPlayer} has connected previously under a different alias"); + Logger.WriteDebug($"Client {polledPlayer} has connected previously under a different ip/name"); client.CurrentAlias = new SharedLibrary.Database.Models.EFAlias() { IPAddress = polledPlayer.IPAddress, Name = polledPlayer.Name, }; + // we need to update their new ip and name to the virtual property + client.Name = polledPlayer.Name; + client.IPAddress = polledPlayer.IPAddress; + await Manager.GetClientService().Update(client); } player = client.AsPlayer(); diff --git a/Plugins/SimpleStats/Commands/ViewStats.cs b/Plugins/SimpleStats/Commands/ViewStats.cs index 8da99a00d..a0fb2e924 100644 --- a/Plugins/SimpleStats/Commands/ViewStats.cs +++ b/Plugins/SimpleStats/Commands/ViewStats.cs @@ -24,8 +24,13 @@ namespace StatsPlugin.Commands public override async Task ExecuteAsync(Event E) { + if (E.Target?.ClientNumber < 0) + { + await E.Origin.Tell("The specified player must be ingame"); + return; + } - if (E.Origin.ClientNumber < 0) + if (E.Origin.ClientNumber < 0 && E.Target == null) { await E.Origin.Tell("You must be ingame to view your stats"); return; @@ -45,7 +50,7 @@ namespace StatsPlugin.Commands if (E.Target != null) { - pStats = clientStats.Find(c => c.ServerId ==serverId && c.ClientId == E.Target.ClientId).First(); + pStats = clientStats.Find(c => c.ServerId == serverId && c.ClientId == E.Target.ClientId).First(); statLine = String.Format("^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", pStats.Kills, pStats.Deaths, pStats.KDR, pStats.Skill); } diff --git a/Plugins/SimpleStats/Plugin.cs b/Plugins/SimpleStats/Plugin.cs index 466ceb466..269274739 100644 --- a/Plugins/SimpleStats/Plugin.cs +++ b/Plugins/SimpleStats/Plugin.cs @@ -41,7 +41,7 @@ namespace StatsPlugin await Manager.RemovePlayer(E.Origin); break; case Event.GType.Say: - if (E.Data != string.Empty && E.Data.Trim().Length > 0) + if (E.Data != string.Empty && E.Data.Trim().Length > 0 && E.Data[0] != '!') await Manager.AddMessageAsync(E.Origin.ClientId, E.Owner.GetHashCode(), E.Data); break; case Event.GType.MapChange: diff --git a/SharedLibrary/Commands/NativeCommands.cs b/SharedLibrary/Commands/NativeCommands.cs index 41ab7326a..6b169ed30 100644 --- a/SharedLibrary/Commands/NativeCommands.cs +++ b/SharedLibrary/Commands/NativeCommands.cs @@ -429,15 +429,22 @@ namespace SharedLibrary.Commands if (newPerm > Player.Permission.Banned) { var ActiveClient = E.Owner.Manager.GetActiveClients().FirstOrDefault(p => p.NetworkId == E.Target.NetworkId); - ActiveClient.Level = newPerm; + if (ActiveClient != null) + { + ActiveClient.Level = newPerm; await ActiveClient.Tell("Congratulations! You have been promoted to ^3" + newPerm); + } + + else + { + E.Target.Level = newPerm; + await E.Owner.Manager.GetClientService().Update(E.Target); + } await E.Origin.Tell($"{E.Target.Name} was successfully promoted!"); - E.Target.Level = newPerm; - await E.Owner.Manager.GetClientService().Update(E.Target); } else diff --git a/SharedLibrary/Dtos/PenaltyInfo.cs b/SharedLibrary/Dtos/PenaltyInfo.cs index 70e3b9ba1..425726047 100644 --- a/SharedLibrary/Dtos/PenaltyInfo.cs +++ b/SharedLibrary/Dtos/PenaltyInfo.cs @@ -12,6 +12,7 @@ namespace SharedLibrary.Dtos public int OffenderId { get; set; } public string PunisherName { get; set; } public int PunisherId { get; set; } + public string PunisherLevel { get; set; } public string Offense { get; set; } public string Type { get; set; } public string TimePunished { get; set; } diff --git a/SharedLibrary/Services/ClientService.cs b/SharedLibrary/Services/ClientService.cs index 949cbf76a..e49b16eee 100644 --- a/SharedLibrary/Services/ClientService.cs +++ b/SharedLibrary/Services/ClientService.cs @@ -174,7 +174,7 @@ namespace SharedLibrary.Services client.Connections = entity.Connections; client.FirstConnection = entity.FirstConnection; client.Masked = entity.Masked; - client.TotalConnectionTime = entity.TotalConnectionTime; + client.TotalConnectionTime = entity.TotalConnectionTime; // update in database await context.SaveChangesAsync(); diff --git a/WebfrontCore/Controllers/ClientController.cs b/WebfrontCore/Controllers/ClientController.cs index 85d15be38..28a8d65be 100644 --- a/WebfrontCore/Controllers/ClientController.cs +++ b/WebfrontCore/Controllers/ClientController.cs @@ -44,6 +44,8 @@ namespace WebfrontCore.Controllers clientDto.Meta.AddRange(await IW4MAdmin.ApplicationManager.GetInstance().GetPenaltyService().ReadGetClientPenaltiesAsync(client.ClientId, false)); clientDto.Meta = clientDto.Meta.OrderByDescending(m => m.When).ToList(); + ViewBag.Title = clientDto.Name; + return View("Profile/Index", clientDto); } diff --git a/WebfrontCore/Controllers/ConsoleController.cs b/WebfrontCore/Controllers/ConsoleController.cs index 0724cf19e..c6b3c42d4 100644 --- a/WebfrontCore/Controllers/ConsoleController.cs +++ b/WebfrontCore/Controllers/ConsoleController.cs @@ -28,6 +28,7 @@ namespace WebfrontCore.Controllers var requestIPAddress = Request.HttpContext.Connection.RemoteIpAddress; var intIP = requestIPAddress.ToString().ConvertToIP(); +#if !DEBUG var origin = (await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().GetClientByIP(intIP)) .OrderByDescending(c => c.Level) .FirstOrDefault()?.AsPlayer() ?? new Player() @@ -36,6 +37,9 @@ namespace WebfrontCore.Controllers Level = Player.Permission.User, IPAddress = intIP }; +#else + var origin = (await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().GetUnique(0)).AsPlayer(); +#endif var server = IW4MAdmin.ApplicationManager.GetInstance().Servers.First(s => s.GetHashCode() == serverId); origin.CurrentServer = server; diff --git a/WebfrontCore/Program.cs b/WebfrontCore/Program.cs index bb6cbbbc9..f0c3967b2 100644 --- a/WebfrontCore/Program.cs +++ b/WebfrontCore/Program.cs @@ -19,7 +19,7 @@ namespace WebfrontCore #if !DEBUG .UseUrls("http://server.nbsclan.org:8080") #else - .UseUrls("http://192.168.88.254:5000") + .UseUrls("http://127.0.0.1:5000;http://192.168.88.254:5000") #endif .Build(); diff --git a/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs b/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs index ad739721d..9cbacace5 100644 --- a/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs +++ b/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs @@ -19,6 +19,7 @@ namespace WebfrontCore.ViewComponents OffenderName = p.Offender.Name, PunisherId = p.PunisherId, PunisherName = p.Punisher.Name, + PunisherLevel = p.Punisher.Level.ToString(), Offense = p.Offense, Type = p.Type.ToString(), TimePunished = Utilities.GetTimePassed(p.When, false), diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index 54ff7e517..bd5ae00f3 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -8,7 +8,7 @@