From 2cceb2f3e7674e4e7b4d9c8a01068ff9099ab3aa Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 28 Apr 2019 20:54:11 -0500 Subject: [PATCH] make database seed code less verbose disable killserver command fix issue with default parser not saving during setup fix issue with unban reason displayed when player is rebanned --- Application/ApplicationManager.cs | 2 +- SharedLibraryCore/Commands/NativeCommands.cs | 4 +-- .../QuickMessageConfiguration.cs | 1 - .../Configuration/ServerConfiguration.cs | 6 ++-- SharedLibraryCore/Database/ContextSeed.cs | 28 ++++++------------- SharedLibraryCore/Objects/EFClient.cs | 2 +- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index a94b01af..88d9d457 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -387,7 +387,7 @@ namespace IW4MAdmin.Application Commands.Add(new CIP()); Commands.Add(new CMask()); Commands.Add(new CPruneAdmins()); - Commands.Add(new CKillServer()); + //Commands.Add(new CKillServer()); Commands.Add(new CSetPassword()); Commands.Add(new CPing()); Commands.Add(new CSetGravatar()); diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs index 02a85a95..5ce31bf9 100644 --- a/SharedLibraryCore/Commands/NativeCommands.cs +++ b/SharedLibraryCore/Commands/NativeCommands.cs @@ -1135,12 +1135,12 @@ namespace SharedLibraryCore.Commands public override async Task ExecuteAsync(GameEvent E) { - if (E.Owner.ServerConfig.ManualLogPath != null) + if (E.Owner.ServerConfig.GameLogServerUrl != null) { using (var wc = new WebClient()) { E.Owner.RestartRequested = true; - var response = await wc.DownloadStringTaskAsync(new Uri($"{E.Owner.ServerConfig.ManualLogPath}/restart")); + var response = await wc.DownloadStringTaskAsync(new Uri($"{E.Owner.ServerConfig.GameLogServerUrl}/restart")); } } diff --git a/SharedLibraryCore/Configuration/QuickMessageConfiguration.cs b/SharedLibraryCore/Configuration/QuickMessageConfiguration.cs index 22438d77..852c04fe 100644 --- a/SharedLibraryCore/Configuration/QuickMessageConfiguration.cs +++ b/SharedLibraryCore/Configuration/QuickMessageConfiguration.cs @@ -7,7 +7,6 @@ namespace SharedLibraryCore.Configuration { public class QuickMessageConfiguration { - public Game Game { get; set; } public Dictionary Messages { get; set; } } diff --git a/SharedLibraryCore/Configuration/ServerConfiguration.cs b/SharedLibraryCore/Configuration/ServerConfiguration.cs index 6b5a5bf9..082bf71b 100644 --- a/SharedLibraryCore/Configuration/ServerConfiguration.cs +++ b/SharedLibraryCore/Configuration/ServerConfiguration.cs @@ -58,11 +58,11 @@ namespace SharedLibraryCore.Configuration var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray(); var selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_RCON_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions); - if (selection.Item1 > 0) + if (selection.Item1 >= 0) { RConParserVersion = selection.Item2; - if (!rconParsers[selection.Item1 - 1].CanGenerateLogPath) + if (selection.Item1 > 0 && !rconParsers[selection.Item1 - 1].CanGenerateLogPath) { Console.WriteLine(loc["SETUP_SERVER_NO_LOG"]); ManualLogPath = Utilities.PromptString(loc["SETUP_SERVER_LOG_PATH"]); @@ -72,7 +72,7 @@ namespace SharedLibraryCore.Configuration parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray(); selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_EVENT_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions); - if (selection.Item1 > 0) + if (selection.Item1 >= 0) { EventParserVersion = selection.Item2; } diff --git a/SharedLibraryCore/Database/ContextSeed.cs b/SharedLibraryCore/Database/ContextSeed.cs index 1c7ebe4f..028eae8c 100644 --- a/SharedLibraryCore/Database/ContextSeed.cs +++ b/SharedLibraryCore/Database/ContextSeed.cs @@ -18,27 +18,11 @@ namespace SharedLibraryCore.Database public async Task Seed() { - // make sure database exists - //context.Database.EnsureCreated(); context.Database.Migrate(); if (context.AliasLinks.Count() == 0) { - context.AliasLinks.Add(new EFAliasLink() - { - AliasLinkId = 1 - }); - - var currentAlias = new EFAlias() - { - AliasId = 1, - Active = true, - DateAdded = DateTime.UtcNow, - Name = "IW4MAdmin", - LinkId = 1 - }; - - context.Aliases.Add(currentAlias); + var link = new EFAliasLink(); context.Clients.Add(new EFClient() { @@ -50,8 +34,14 @@ namespace SharedLibraryCore.Database Level = Permission.Console, Masked = true, NetworkId = 0, - AliasLinkId = 1, - CurrentAliasId = 1, + AliasLink = link, + CurrentAlias = new EFAlias() + { + Link = link, + Active = true, + DateAdded = DateTime.UtcNow, + Name = "IW4MAdmin", + }, }); await context.SaveChangesAsync(); diff --git a/SharedLibraryCore/Objects/EFClient.cs b/SharedLibraryCore/Objects/EFClient.cs index da244ced..c7ca5d98 100644 --- a/SharedLibraryCore/Objects/EFClient.cs +++ b/SharedLibraryCore/Objects/EFClient.cs @@ -538,7 +538,7 @@ namespace SharedLibraryCore.Database.Models // kick them as their level is banned if (Level == Permission.Banned) { - var profileBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Expires == null && _penalty.Active); + var profileBan = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Expires == null && _penalty.Active && _penalty.Type == Penalty.PenaltyType.Ban); if (profileBan == null) {