From 02a784ad0927948f5cd8ddbf60f01b9debf5aba1 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 17 Feb 2020 10:05:31 -0600 Subject: [PATCH] allow prompt string to have an empty/default value upgrade some project dependencies don't try to run events on parsers update top players rank distribution --- Application/Application.csproj | 1 + Application/IW4MServer.cs | 9 ++++++++- Application/Misc/ScriptPlugin.cs | 8 +++++++- Plugins/IW4ScriptCommands/GscApiController.cs | 3 ++- .../Stats/Components/TopPlayers/_List.cshtml | 16 ++++++++-------- SharedLibraryCore/SharedLibraryCore.csproj | 7 +++---- SharedLibraryCore/Utilities.cs | 2 +- 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Application/Application.csproj b/Application/Application.csproj index 0f73533c6..e68fb48f0 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -24,6 +24,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 21ecc8884..97a63ac6a 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -1,5 +1,6 @@ using IW4MAdmin.Application.EventParsers; using IW4MAdmin.Application.IO; +using IW4MAdmin.Application.Misc; using IW4MAdmin.Application.RconParsers; using SharedLibraryCore; using SharedLibraryCore.Configuration; @@ -157,6 +158,12 @@ namespace IW4MAdmin { try { + // we don't want to run the events on parser plugins + if (plugin is ScriptPlugin scriptPlugin && scriptPlugin.IsParser) + { + continue; + } + await plugin.OnEventAsync(E, this); } catch (AuthorizationException e) @@ -183,7 +190,7 @@ namespace IW4MAdmin { lastException = e; - if (E.Origin != null) + if (E.Origin != null && E.Type == GameEvent.EventType.Command) { E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]); } diff --git a/Application/Misc/ScriptPlugin.cs b/Application/Misc/ScriptPlugin.cs index c596ee809..9a6c7f3b5 100644 --- a/Application/Misc/ScriptPlugin.cs +++ b/Application/Misc/ScriptPlugin.cs @@ -23,6 +23,11 @@ namespace IW4MAdmin.Application.Misc public string Author { get; set; } + /// + /// indicates if the plugin is a parser + /// + public bool IsParser { get; private set; } + public FileSystemWatcher Watcher { get; private set; } private Engine _scriptEngine; @@ -107,6 +112,7 @@ namespace IW4MAdmin.Application.Misc { if (pluginObject.isParser) { + IsParser = true; IEventParser eventParser = (IEventParser)_scriptEngine.GetValue("eventParser").ToObject(); IRConParser rconParser = (IRConParser)_scriptEngine.GetValue("rconParser").ToObject(); manager.AdditionalEventParsers.Add(eventParser); @@ -149,7 +155,7 @@ namespace IW4MAdmin.Application.Misc _scriptEngine.SetValue("_gameEvent", E); _scriptEngine.SetValue("_server", S); _scriptEngine.SetValue("_IW4MAdminClient", Utilities.IW4MAdminClient(S)); - await Task.FromResult(_scriptEngine.Execute("plugin.onEventAsync(_gameEvent, _server)").GetCompletionValue()); + _scriptEngine.Execute("plugin.onEventAsync(_gameEvent, _server)").GetCompletionValue(); } catch diff --git a/Plugins/IW4ScriptCommands/GscApiController.cs b/Plugins/IW4ScriptCommands/GscApiController.cs index 9a846f83c..edadf8660 100644 --- a/Plugins/IW4ScriptCommands/GscApiController.cs +++ b/Plugins/IW4ScriptCommands/GscApiController.cs @@ -22,8 +22,9 @@ namespace WebfrontCore.Controllers.API [HttpGet("{networkId}")] public IActionResult ClientInfo(string networkId) { + long decimalNetworkId = networkId.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber); var clientInfo = Manager.GetActiveClients() - .FirstOrDefault(c => c.NetworkId == networkId.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber)); + .FirstOrDefault(c => c.NetworkId == decimalNetworkId); if (clientInfo != null) { diff --git a/Plugins/Web/StatsWeb/Views/Stats/Components/TopPlayers/_List.cshtml b/Plugins/Web/StatsWeb/Views/Stats/Components/TopPlayers/_List.cshtml index 1df5f7b15..7084e5801 100644 --- a/Plugins/Web/StatsWeb/Views/Stats/Components/TopPlayers/_List.cshtml +++ b/Plugins/Web/StatsWeb/Views/Stats/Components/TopPlayers/_List.cshtml @@ -5,21 +5,21 @@ double getDeviation(double deviations) => Math.Pow(Math.E, 5.0813 + (deviations * 0.8694)); string rankIcon(double elo) { - if (elo >= getDeviation(-1) && elo < getDeviation(-0.25)) + if (elo >= getDeviation(-0.75) && elo < getDeviation(1.25)) return "0_no-place/menu_div_no_place.png"; - if (elo >= getDeviation(-0.25) && elo < getDeviation(0.25)) + if (elo >= getDeviation(0.125) && elo < getDeviation(0.625)) return "1_iron/menu_div_iron_sub03.png"; - if (elo >= getDeviation(0.25) && elo < getDeviation(0.6875)) + if (elo >= getDeviation(0.625) && elo < getDeviation(1.0)) return "2_bronze/menu_div_bronze_sub03.png"; - if (elo >= getDeviation(0.6875) && elo < getDeviation(1)) + if (elo >= getDeviation(1.0) && elo < getDeviation(1.25)) return "3_silver/menu_div_silver_sub03.png"; - if (elo >= getDeviation(1) && elo < getDeviation(1.25)) - return "4_gold/menu_div_gold_sub03.png"; if (elo >= getDeviation(1.25) && elo < getDeviation(1.5)) - return "5_platinum/menu_div_platinum_sub03.png"; + return "4_gold/menu_div_gold_sub03.png"; if (elo >= getDeviation(1.5) && elo < getDeviation(1.75)) + return "5_platinum/menu_div_platinum_sub03.png"; + if (elo >= getDeviation(1.75) && elo < getDeviation(2.0)) return "6_semipro/menu_div_semipro_sub03.png"; - if (elo >= getDeviation(1.75)) + if (elo >= getDeviation(2.0)) return "7_pro/menu_div_pro_sub03.png"; return "0_no-place/menu_div_no_place.png"; diff --git a/SharedLibraryCore/SharedLibraryCore.csproj b/SharedLibraryCore/SharedLibraryCore.csproj index cc9c5e082..b4ca8e0cb 100644 --- a/SharedLibraryCore/SharedLibraryCore.csproj +++ b/SharedLibraryCore/SharedLibraryCore.csproj @@ -47,7 +47,6 @@ - @@ -63,9 +62,9 @@ - - - + + + diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 00ddae4d7..06a6c6868 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -645,7 +645,7 @@ namespace SharedLibraryCore { Console.Write($"{question}{(string.IsNullOrEmpty(description) ? "" : $" ({description})")}{(defaultValue == null ? "" : $" [{CurrentLocalization.LocalizationIndex["SETUP_PROMPT_DEFAULT"]} {defaultValue}]")}: "); response = inputOrDefault(); - } while (string.IsNullOrWhiteSpace(response)); + } while (string.IsNullOrWhiteSpace(response) && response != defaultValue); return response; }