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
This commit is contained in:
RaidMax 2020-02-17 10:05:31 -06:00
parent 2e5ffe91fc
commit 02a784ad09
7 changed files with 30 additions and 16 deletions

View File

@ -24,6 +24,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Jint" Version="3.0.0-beta-1632" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -1,5 +1,6 @@
using IW4MAdmin.Application.EventParsers; using IW4MAdmin.Application.EventParsers;
using IW4MAdmin.Application.IO; using IW4MAdmin.Application.IO;
using IW4MAdmin.Application.Misc;
using IW4MAdmin.Application.RconParsers; using IW4MAdmin.Application.RconParsers;
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Configuration; using SharedLibraryCore.Configuration;
@ -157,6 +158,12 @@ namespace IW4MAdmin
{ {
try 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); await plugin.OnEventAsync(E, this);
} }
catch (AuthorizationException e) catch (AuthorizationException e)
@ -183,7 +190,7 @@ namespace IW4MAdmin
{ {
lastException = e; lastException = e;
if (E.Origin != null) if (E.Origin != null && E.Type == GameEvent.EventType.Command)
{ {
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]); E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
} }

View File

@ -23,6 +23,11 @@ namespace IW4MAdmin.Application.Misc
public string Author { get; set; } public string Author { get; set; }
/// <summary>
/// indicates if the plugin is a parser
/// </summary>
public bool IsParser { get; private set; }
public FileSystemWatcher Watcher { get; private set; } public FileSystemWatcher Watcher { get; private set; }
private Engine _scriptEngine; private Engine _scriptEngine;
@ -107,6 +112,7 @@ namespace IW4MAdmin.Application.Misc
{ {
if (pluginObject.isParser) if (pluginObject.isParser)
{ {
IsParser = true;
IEventParser eventParser = (IEventParser)_scriptEngine.GetValue("eventParser").ToObject(); IEventParser eventParser = (IEventParser)_scriptEngine.GetValue("eventParser").ToObject();
IRConParser rconParser = (IRConParser)_scriptEngine.GetValue("rconParser").ToObject(); IRConParser rconParser = (IRConParser)_scriptEngine.GetValue("rconParser").ToObject();
manager.AdditionalEventParsers.Add(eventParser); manager.AdditionalEventParsers.Add(eventParser);
@ -149,7 +155,7 @@ namespace IW4MAdmin.Application.Misc
_scriptEngine.SetValue("_gameEvent", E); _scriptEngine.SetValue("_gameEvent", E);
_scriptEngine.SetValue("_server", S); _scriptEngine.SetValue("_server", S);
_scriptEngine.SetValue("_IW4MAdminClient", Utilities.IW4MAdminClient(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 catch

View File

@ -22,8 +22,9 @@ namespace WebfrontCore.Controllers.API
[HttpGet("{networkId}")] [HttpGet("{networkId}")]
public IActionResult ClientInfo(string networkId) public IActionResult ClientInfo(string networkId)
{ {
long decimalNetworkId = networkId.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber);
var clientInfo = Manager.GetActiveClients() var clientInfo = Manager.GetActiveClients()
.FirstOrDefault(c => c.NetworkId == networkId.ConvertGuidToLong(System.Globalization.NumberStyles.HexNumber)); .FirstOrDefault(c => c.NetworkId == decimalNetworkId);
if (clientInfo != null) if (clientInfo != null)
{ {

View File

@ -5,21 +5,21 @@
double getDeviation(double deviations) => Math.Pow(Math.E, 5.0813 + (deviations * 0.8694)); double getDeviation(double deviations) => Math.Pow(Math.E, 5.0813 + (deviations * 0.8694));
string rankIcon(double elo) 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"; 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"; 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"; 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"; 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)) 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)) 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"; 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 "7_pro/menu_div_pro_sub03.png";
return "0_no-place/menu_div_no_place.png"; return "0_no-place/menu_div_no_place.png";

View File

@ -47,7 +47,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentValidation" Version="8.6.1" /> <PackageReference Include="FluentValidation" Version="8.6.1" />
<PackageReference Include="Jint" Version="2.11.58" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
@ -63,9 +62,9 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.1" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Npgsql" Version="4.1.2" /> <PackageReference Include="Npgsql" Version="4.1.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.1.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" /> <PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -645,7 +645,7 @@ namespace SharedLibraryCore
{ {
Console.Write($"{question}{(string.IsNullOrEmpty(description) ? "" : $" ({description})")}{(defaultValue == null ? "" : $" [{CurrentLocalization.LocalizationIndex["SETUP_PROMPT_DEFAULT"]} {defaultValue}]")}: "); Console.Write($"{question}{(string.IsNullOrEmpty(description) ? "" : $" ({description})")}{(defaultValue == null ? "" : $" [{CurrentLocalization.LocalizationIndex["SETUP_PROMPT_DEFAULT"]} {defaultValue}]")}: ");
response = inputOrDefault(); response = inputOrDefault();
} while (string.IsNullOrWhiteSpace(response)); } while (string.IsNullOrWhiteSpace(response) && response != defaultValue);
return response; return response;
} }