fix for issue #70

update start script for windows
This commit is contained in:
RaidMax 2019-03-18 10:36:31 -05:00
parent 95e4ee672e
commit 1056c7c335
4 changed files with 41 additions and 30 deletions

View File

@ -6,7 +6,7 @@
<RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
<Version>2.2.5.7</Version>
<Version>2.2.5.8</Version>
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Product>IW4MAdmin</Product>
@ -31,8 +31,8 @@
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<TieredCompilation>true</TieredCompilation>
<AssemblyVersion>2.2.5.7</AssemblyVersion>
<FileVersion>2.2.5.6</FileVersion>
<AssemblyVersion>2.2.5.8</AssemblyVersion>
<FileVersion>2.2.5.8</FileVersion>
</PropertyGroup>
<ItemGroup>

View File

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

View File

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

View File

@ -18,10 +18,12 @@ namespace SharedLibraryCore.Configuration
public void Build()
{
var configContent = File.ReadAllText(_configurationPath);
_configuration = JsonConvert.DeserializeObject<T>(configContent);
if (_configuration == null)
try
{
var configContent = File.ReadAllText(_configurationPath);
_configuration = JsonConvert.DeserializeObject<T>(configContent);
}
catch
{
_configuration = default(T);
}