1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

cleaned up configuration files to use appsettings

This commit is contained in:
RaidMax
2018-03-14 00:36:25 -05:00
parent c3d5f6ac26
commit d836f71b1b
22 changed files with 199 additions and 170 deletions

View File

@ -424,9 +424,9 @@ namespace SharedLibrary.Commands
if (newPerm == Player.Permission.Owner && E.Origin.Level != Player.Permission.Console)
newPerm = Player.Permission.Banned;
if (newPerm == Player.Permission.Owner && !E.Owner.Config.AllowMultipleOwners)
if (newPerm == Player.Permission.Owner && !E.Owner.Manager.GetApplicationSettings().EnableMultipleOwners)
{
await E.Origin.Tell("There can only be 1 owner. Modify your server configuration if multiple owners are required");
await E.Origin.Tell("There can only be 1 owner. Modify your appsettings if multiple owners are required");
return;
}
@ -1033,13 +1033,15 @@ namespace SharedLibrary.Commands
#endif
process.StartInfo.FileName = $"{process.StartInfo.WorkingDirectory}\\iw4x.exe";
process.StartInfo.Arguments = commandLine.Substring(6);
process.StartInfo.UserName = E.Owner.Config.RestartUsername;
/*process.StartInfo.UserName = E.Owner.ServerConfig.RestartUsername;
var pw = new System.Security.SecureString();
foreach (char c in E.Owner.Config.RestartPassword)
foreach (char c in E.Owner.ServerConfig.RestartPassword)
pw.AppendChar(c);
process.StartInfo.Password = pw;
*/
process.Start();
}

View File

@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace SharedLibrary.Configuration
{
public class ApplicationConfiguration
{
public bool EnableMultipleOwners { get; set; }
public bool EnableTrustedRank { get; set; }
public bool EnableClientVPNs { get; set; }
public bool EnableAntiCheat { get; set; }
public bool EnableDiscordLink { get; set; }
public string DiscordInviteCode { get; set; }
public string IPHubAPIKey { get; set; }
public List<ServerConfiguration> Servers { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace SharedLibrary.Configuration
{
public class ServerConfiguration
{
public string IPAddress { get; set; }
public short Port { get; set; }
public string Password { get; set; }
}
}

View File

@ -3,6 +3,8 @@ using SharedLibrary.Objects;
using SharedLibrary.Database.Models;
using SharedLibrary.Services;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using SharedLibrary.Configuration;
namespace SharedLibrary.Interfaces
{
@ -16,6 +18,7 @@ namespace SharedLibrary.Interfaces
IList<Command> GetCommands();
IList<Helpers.MessageToken> GetMessageTokens();
IList<Player> GetActiveClients();
ApplicationConfiguration GetApplicationSettings();
ClientService GetClientService();
AliasService GetAliasService();
PenaltyService GetPenaltyService();

View File

@ -11,6 +11,7 @@ using System.Threading.Tasks;
using SharedLibrary.Helpers;
using SharedLibrary.Objects;
using SharedLibrary.Dtos;
using SharedLibrary.Configuration;
namespace SharedLibrary
{
@ -30,11 +31,11 @@ namespace SharedLibrary
public Server(Interfaces.IManager mgr, ServerConfiguration config)
{
Password = config.Password;
IP = config.IP;
IP = config.IPAddress;
Port = config.Port;
Manager = mgr;
Logger = Manager.GetLogger();
Config = config;
ServerConfig = config;
Players = new List<Player>(new Player[18]);
Reports = new List<Report>();
@ -360,7 +361,7 @@ namespace SharedLibrary
// Objects
public Interfaces.IManager Manager { get; protected set; }
public Interfaces.ILogger Logger { get; private set; }
public ServerConfiguration Config { get; private set; }
public ServerConfiguration ServerConfig { get; private set; }
public List<Map> Maps { get; protected set; }
public List<string> Rules { get; protected set; }
public List<Report> Reports { get; set; }

View File

@ -1,23 +0,0 @@
using SharedLibrary.Interfaces;
namespace SharedLibrary
{
public class ServerConfiguration : Serialize<ServerConfiguration>
{
public string IP;
public int Port;
public string Password;
public string FtpPrefix;
public bool AllowMultipleOwners;
public bool AllowTrustedRank;
public string RestartUsername;
public string RestartPassword;
public bool EnableAntiCheat;
public bool AllowClientVpn;
public override string Filename()
{
return $"{Utilities.OperatingDirectory}config/servers/{IP}_{Port}.cfg";
}
}
}

View File

@ -146,6 +146,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\ServerConfiguration.cs" />
<Compile Include="Database\Importer.cs" />
<Compile Include="Database\DatabaseContext.cs" />
<Compile Include="Database\Models\EFAlias.cs" />
@ -198,7 +199,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RCON.cs" />
<Compile Include="Server.cs" />
<Compile Include="ServerConfiguration.cs" />
<Compile Include="Configuration\ApplicationConfiguration.cs" />
<Compile Include="Services\AliasService.cs" />
<Compile Include="Services\ClientService.cs" />
<Compile Include="Services\GenericRepository.cs" />
@ -226,6 +227,9 @@
<PackageReference Include="EntityFramework.SqlServerCompact">
<Version>6.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions">
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.1</Version>
</PackageReference>