diff --git a/Application/Application.csproj b/Application/Application.csproj index 063372a6..99421ecb 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.2.2 false RaidMax.IW4MAdmin.Application - 2.2.5.7 + 2.2.5.8 RaidMax Forever None IW4MAdmin @@ -31,8 +31,8 @@ true true - 2.2.5.7 - 2.2.5.6 + 2.2.5.8 + 2.2.5.8 diff --git a/Application/BuildScripts/PostPublish.bat b/Application/BuildScripts/PostPublish.bat index 46922feb..f9c4d92a 100644 --- a/Application/BuildScripts/PostPublish.bat +++ b/Application/BuildScripts/PostPublish.bat @@ -98,8 +98,8 @@ if "%CurrentConfiguration%" == "Release" ( ) echo making start scripts -@(echo dotnet Lib\IW4MAdmin.dll && echo pause) > "%SolutionDir%Publish\WindowsPrerelease\StartIW4MAdmin.cmd" -@(echo dotnet Lib\IW4MAdmin.dll && echo pause) > "%SolutionDir%Publish\Windows\StartIW4MAdmin.cmd" +@(echo @echo off && echo @title IW4MAdmin && echo dotnet Lib\IW4MAdmin.dll && echo pause) > "%SolutionDir%Publish\WindowsPrerelease\StartIW4MAdmin.cmd" +@(echo @echo off && echo @title IW4MAdmin && echo dotnet Lib\IW4MAdmin.dll && echo pause) > "%SolutionDir%Publish\Windows\StartIW4MAdmin.cmd" @(echo #!/bin/bash && echo dotnet Lib/IW4MAdmin.dll) > "%SolutionDir%Publish\WindowsPrerelease\StartIW4MAdmin.sh" @(echo #!/bin/bash && echo dotnet Lib/IW4MAdmin.dll) > "%SolutionDir%Publish\Windows\StartIW4MAdmin.sh" diff --git a/SharedLibraryCore/Commands/CommandProcessing.cs b/SharedLibraryCore/Commands/CommandProcessing.cs index fe100a27..5d05b22d 100644 --- a/SharedLibraryCore/Commands/CommandProcessing.cs +++ b/SharedLibraryCore/Commands/CommandProcessing.cs @@ -1,6 +1,5 @@ using SharedLibraryCore.Database.Models; using SharedLibraryCore.Exceptions; -using SharedLibraryCore.Objects; using System; using System.Collections.Generic; using System.Linq; @@ -23,7 +22,9 @@ namespace SharedLibraryCore.Commands foreach (Command cmd in Manager.GetCommands()) { if (cmd.Name == CommandString.ToLower() || cmd.Alias == CommandString.ToLower()) + { C = cmd; + } } if (C == null) @@ -34,6 +35,7 @@ namespace SharedLibraryCore.Commands E.Data = E.Data.RemoveWords(1); String[] Args = E.Data.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + // todo: the code below can be cleaned up if (E.Origin.Level < C.Permission) { @@ -48,31 +50,36 @@ namespace SharedLibraryCore.Commands throw new CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\""); } - if (C.RequiresTarget || Args.Length > 0) + if (C.RequiresTarget) { - if (!Int32.TryParse(Args[0], out int cNum)) - cNum = -1; - - if (Args[0][0] == '@') // user specifying target by database ID + if (Args.Length > 0) { - int dbID = -1; - int.TryParse(Args[0].Substring(1, Args[0].Length - 1), out dbID); - - var found = await Manager.GetClientService().Get(dbID); - if (found != null) + if (!Int32.TryParse(Args[0], out int cNum)) { - E.Target = found; - E.Target.CurrentServer = E.Owner; - E.Data = String.Join(" ", Args.Skip(1)); + cNum = -1; } - } - else if (Args[0].Length < 3 && cNum > -1 && cNum < E.Owner.MaxClients) // user specifying target by client num - { - if (E.Owner.Clients[cNum] != null) + if (Args[0][0] == '@') // user specifying target by database ID { - E.Target = E.Owner.Clients[cNum]; - E.Data = String.Join(" ", Args.Skip(1)); + int dbID = -1; + int.TryParse(Args[0].Substring(1, Args[0].Length - 1), out dbID); + + var found = await Manager.GetClientService().Get(dbID); + if (found != null) + { + E.Target = found; + E.Target.CurrentServer = E.Owner; + E.Data = String.Join(" ", Args.Skip(1)); + } + } + + else if (Args[0].Length < 3 && cNum > -1 && cNum < E.Owner.MaxClients) // user specifying target by client num + { + if (E.Owner.Clients[cNum] != null) + { + E.Target = E.Owner.Clients[cNum]; + E.Data = String.Join(" ", Args.Skip(1)); + } } } @@ -103,7 +110,7 @@ namespace SharedLibraryCore.Commands } } - if (E.Target == null && C.RequiresTarget) // Find active player as single word + if (E.Target == null && C.RequiresTarget && Args.Length > 0) // Find active player as single word { matchingPlayers = E.Owner.GetClientByName(Args[0]); if (matchingPlayers.Count > 1) @@ -115,6 +122,7 @@ namespace SharedLibraryCore.Commands } throw new CommandException($"{E.Origin} had multiple players found for {C.Name}"); } + else if (matchingPlayers.Count == 1) { E.Target = matchingPlayers.First(); @@ -141,6 +149,7 @@ namespace SharedLibraryCore.Commands throw new CommandException($"{E.Origin} specified invalid player for \"{C.Name}\""); } } + E.Data = E.Data.Trim(); return C; } diff --git a/SharedLibraryCore/Helpers/BaseConfigurationHandler.cs b/SharedLibraryCore/Helpers/BaseConfigurationHandler.cs index 6a84d664..ed06cde3 100644 --- a/SharedLibraryCore/Helpers/BaseConfigurationHandler.cs +++ b/SharedLibraryCore/Helpers/BaseConfigurationHandler.cs @@ -18,10 +18,12 @@ namespace SharedLibraryCore.Configuration public void Build() { - var configContent = File.ReadAllText(_configurationPath); - _configuration = JsonConvert.DeserializeObject(configContent); - - if (_configuration == null) + try + { + var configContent = File.ReadAllText(_configurationPath); + _configuration = JsonConvert.DeserializeObject(configContent); + } + catch { _configuration = default(T); }