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 @@
-

@Model.Name

+

@Model.Name

@{ foreach (string alias in Model.Aliases) @@ -31,10 +31,11 @@ Last seen @Model.LastSeen ago
-
- +
+
+
@{ diff --git a/WebfrontCore/Views/Penalty/_Penalty.cshtml b/WebfrontCore/Views/Penalty/_Penalty.cshtml index a11ca1476..07e0d8760 100644 --- a/WebfrontCore/Views/Penalty/_Penalty.cshtml +++ b/WebfrontCore/Views/Penalty/_Penalty.cshtml @@ -28,7 +28,7 @@ Admin - @Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "link-inverse" }) + @Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + Model.PunisherLevel.ToLower() }) @@ -60,7 +60,7 @@ @Model.Offense - @Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "link-inverse" }) + @Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + Model.PunisherLevel.ToLower() }) @{ diff --git a/WebfrontCore/wwwroot/css/profile.css b/WebfrontCore/wwwroot/css/profile.css index c468668b5..fdf6db4ae 100644 --- a/WebfrontCore/wwwroot/css/profile.css +++ b/WebfrontCore/wwwroot/css/profile.css @@ -1,4 +1,7 @@ - +.level-bgcolor-console { + background-color: grey; +} + .level-color-user, .level-color-guest { color: rgba(255, 255, 255, 0.85); } @@ -23,7 +26,7 @@ background-color: rgba(253, 139, 22, 0.85); } -.level-color-banned { +.level-color-banned, .level-color-console { color: rgba(255, 69, 69, 0.85); } diff --git a/WebfrontCore/wwwroot/js/console.js b/WebfrontCore/wwwroot/js/console.js index 54dc85b74..cb18414d0 100644 --- a/WebfrontCore/wwwroot/js/console.js +++ b/WebfrontCore/wwwroot/js/console.js @@ -1,6 +1,16 @@ function executeCommand() { const serverId = $('#console_server_select').val(); const command = $('#console_command_value').val(); + + if (command.length === 0) { + return false; + } + + if (command[0] !== '!') { + $('#console_command_response').text('All commands must start with !').addClass('text-danger'); + return false; + } + $.get('/Console/ExecuteAsync', { serverId: serverId, command: command }) .done(function (response) { $('#console_command_response').html(response); diff --git a/WebfrontCore/wwwroot/js/profile.js b/WebfrontCore/wwwroot/js/profile.js index baa711958..d6d04b8ea 100644 --- a/WebfrontCore/wwwroot/js/profile.js +++ b/WebfrontCore/wwwroot/js/profile.js @@ -1,4 +1,7 @@ -$(document).ready(function () { +// keeps track of how many events have been displayed +let count = 1; + +$(document).ready(function () { /* Expand alias tab if they have any */ @@ -9,14 +12,43 @@ } }); + /* + load the initial 40 events + */ $.each(clientInfo.Meta, function (index, meta) { - loadMeta(meta); - if (count % 40 === 0) { - count++; - return false; + if (meta.key.includes("Event")) { + loadMeta(meta); + if (count % 40 === 0) { + count++; + return false; + } + count++ } - count++ }); + + /* + load additional events on scroll + */ + $(window).scroll(function () { + if ($(window).scrollTop() === $(document).height() - $(window).height() || $(document).height() === $(window).height()) { + while (count % 40 !== 0 && count < clientInfo.Meta.length) { + loadMeta(clientInfo.Meta[count - 1]); + count++; + } + count++; + } + }); + + /* + load meta thats not an event + */ + $.each(clientInfo.Meta, function (index, meta) { + if (!meta.key.includes("Event")) { + let metaString = `
${meta.value} ${meta.key}
`; + $("#profile_meta").append(metaString); + } + }); + }); function penaltyToName(penaltyName) { @@ -55,34 +87,3 @@ function loadMeta(meta) { } $('#profile_events').append(eventString); } - -let count = 1; - -$(document).ready(function () { - $(window).scroll(function () { - if ($(window).scrollTop() === $(document).height() - $(window).height() || $(document).height() === $(window).height()) { - while (count % 40 !== 0 && count < clientInfo.Meta.length) { - loadMeta(clientInfo.Meta[count - 1]); - count++; - } - count++; - } - }); - - $.each(clientInfo.Meta, function (index, meta) { - if (!meta.key.includes("Event")) { - let metaString = `
${meta.value} ${meta.key}
`; - $("#profile_meta").append(metaString); - } - }); - - $.each(clientInfo.Meta, function (index, meta) { - loadMeta(meta); - - if (count % 40 === 0) { - count++; - return false; - } - count++; - }); -}); \ No newline at end of file