diff --git a/Admin/Server.cs b/Admin/Server.cs index cbabe5056..20a682b9a 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -153,12 +153,7 @@ namespace IW4MAdmin Players[NewPlayer.ClientID] = null; Players[NewPlayer.ClientID] = NewPlayer; - Logger.WriteInfo($"Client {NewPlayer.Name}::{NewPlayer.NetworkID} connecting..."); // they're clean - - // todo: get this out of here - while (chatHistory.Count > Math.Ceiling((double)ClientNum / 2)) - chatHistory.RemoveAt(0); - chatHistory.Add(new Chat(NewPlayer.Name, "CONNECTED", DateTime.Now)); + Logger.WriteInfo($"Client {NewPlayer.Name}::{NewPlayer.NetworkID} connecting..."); // they're clean if (NewPlayer.Level > Player.Permission.Moderator) await NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!"); @@ -189,8 +184,6 @@ namespace IW4MAdmin Players[cNum] = null; ClientNum--; - if (ClientNum == 0) - chatHistory.Clear(); } } @@ -533,17 +526,22 @@ namespace IW4MAdmin //Process any server event override protected async Task ProcessEvent(Event E) { + //todo: move + while (ChatHistory.Count > Math.Ceiling((double)ClientNum / 2)) + ChatHistory.RemoveAt(0); + if (E.Type == Event.GType.Connect) { + ChatHistory.Add(new Chat(E.Origin.Name, "CONNECTED", DateTime.Now)); return; } if (E.Type == Event.GType.Disconnect) { + ChatHistory.Add(new Chat(E.Origin.Name, "DISCONNECTED", DateTime.Now)); - while (chatHistory.Count > Math.Ceiling(((double)ClientNum - 1) / 2)) - chatHistory.RemoveAt(0); - chatHistory.Add(new Chat(E.Origin.Name, "DISCONNECTED", DateTime.Now)); + if (ClientNum == 0) + ChatHistory.Clear(); return; } @@ -621,10 +619,8 @@ namespace IW4MAdmin E.Data = E.Data.StripColors().CleanChars(); if (E.Data.Length > 50) E.Data = E.Data.Substring(0, 50) + "..."; - while (chatHistory.Count > Math.Ceiling((double)ClientNum / 2)) - chatHistory.RemoveAt(0); - chatHistory.Add(new Chat(E.Origin.Name, E.Data, DateTime.Now)); + ChatHistory.Add(new Chat(E.Origin.Name, E.Data, DateTime.Now)); return; } @@ -707,9 +703,9 @@ namespace IW4MAdmin // banned from all servers if active foreach (var server in Manager.GetServers()) { - if (server.getPlayers().Count > 0) + if (server.GetPlayersAsList().Count > 0) { - var activeClient = server.getPlayers().Find(x => x.NetworkID == Target.NetworkID); + var activeClient = server.GetPlayersAsList().Find(x => x.NetworkID == Target.NetworkID); if (activeClient != null) await server.ExecuteCommandAsync("tempbanclient " + activeClient.ClientID + " \"" + Message + "^7" + GetWebsiteString() + "^7\""); } diff --git a/Admin/WebService.cs b/Admin/WebService.cs index eb3f31692..9df691966 100644 --- a/Admin/WebService.cs +++ b/Admin/WebService.cs @@ -53,8 +53,7 @@ namespace IW4MAdmin catch (Exception e) { - Manager.GetInstance().Logger.WriteError($"Unable to start webservice ( port is probably in use ): {e.Message}"); - + Manager.GetInstance().Logger.WriteError($"Unable to start webservice ( port is probably in use ): {e.Message}"); } } @@ -196,10 +195,10 @@ namespace IW4MAdmin eachServer.maxPlayers = S.MaxClients; eachServer.mapName = S.CurrentMap.Alias; eachServer.gameType = Utilities.gametypeLocalized(S.getGametype()); - eachServer.currentPlayers = S.getPlayers().Count; - eachServer.chatHistory = S.chatHistory; + eachServer.currentPlayers = S.GetPlayersAsList().Count; + eachServer.chatHistory = S.ChatHistory; eachServer.players = new List(); - foreach (Player P in S.getPlayers()) + foreach (Player P in S.GetPlayersAsList()) { PlayerInfo pInfo = new PlayerInfo(); pInfo.playerID = P.DatabaseID; diff --git a/Admin/lib/SharedLibrary.dll b/Admin/lib/SharedLibrary.dll index e17dbbc4f..0c8582960 100644 Binary files a/Admin/lib/SharedLibrary.dll and b/Admin/lib/SharedLibrary.dll differ diff --git a/Auto Restart Plugin/Auto Restart Plugin.csproj b/Auto Restart Plugin/Auto Restart Plugin.csproj deleted file mode 100644 index 04febaad9..000000000 --- a/Auto Restart Plugin/Auto Restart Plugin.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Debug - AnyCPU - {2321A25F-7871-47C3-8440-02551918D6A1} - Library - Properties - Auto_Restart_Plugin - AutorestartPlugin - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - bin\Release-Stable\ - TRACE - true - pdbonly - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - {d51eeceb-438a-47da-870f-7d7b41bc24d6} - SharedLibrary - False - - - - - - - - copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\bin\$(ConfigurationName)\plugins\AutoRestartPlugin.dll" - - - - -copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\" - - - \ No newline at end of file diff --git a/Auto Restart Plugin/Main.cs b/Auto Restart Plugin/Main.cs deleted file mode 100644 index 2eeb96d1c..000000000 --- a/Auto Restart Plugin/Main.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using SharedLibrary; -using SharedLibrary.Interfaces; -using System.Threading.Tasks; - -#if DEBUG -namespace Auto_Restart_Plugin -{ - public class Main : IPlugin - { - public string Author - { - get - { - return "RaidMax"; - } - } - - public float Version - { - get - { - return 1.0f; - } - } - - public string Name - { - get - { - return "Auto Restart Plugin"; - } - } - - public async Task OnLoadAsync() - { - return; - } - - public async Task OnUnloadAsync() - { - return; - } - - public async Task OnTickAsync(Server S) - { - switch (Monitoring.shouldRestart()) - { - case 300: - await S.Broadcast("^1Server will be performing an ^5AUTOMATIC ^1restart in ^55 ^1minutes."); - break; - case 120: - await S.Broadcast("^1Server will be performing an ^5AUTOMATIC ^1restart in ^52 ^1minutes."); - break; - case 60: - await S.Broadcast("^1Server will be performing an ^5AUTOMATIC ^1restart in ^51 ^1minute."); - break; - case 30: - await S.Broadcast("^1Server will be performing an ^5AUTOMATIC ^1restart in ^530 ^1seconds."); - break; - case 0: - await S.Broadcast("^1Server now performing an ^5AUTOMATIC ^1restart ^5NOW ^1please reconnect."); - Monitoring.Restart(S); - break; - } - } - - public async Task OnEventAsync(Event E, Server S) - { - return; - } - } -} -#endif diff --git a/Auto Restart Plugin/Monitoring.cs b/Auto Restart Plugin/Monitoring.cs deleted file mode 100644 index b403839b3..000000000 --- a/Auto Restart Plugin/Monitoring.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Diagnostics; -using System.Text; -using System.Threading; -using System.Runtime.InteropServices; -using System.Management; -using SharedLibrary; - -namespace Auto_Restart_Plugin -{ - static class Monitoring - { - [DllImport("kernel32")] - public static extern bool DeleteFile(string name); - - public static void Restart(Server goodBye) - { - _Restart(goodBye); - } - - private static void _Restart(Server goodBye) - { - try - { - string cmdLine = GetCommandLine(Process.GetProcessById(goodBye.pID())); - var info = new ProcessStartInfo(); - - // if we don't delete this, we get a prompt.. - DeleteFile(Process.GetProcessById(goodBye.pID()).MainModule.FileName + ":Zone.Identifier"); - - //info.WorkingDirectory = goodBye.Basepath; - info.Arguments = cmdLine; - info.FileName = Process.GetProcessById(goodBye.pID()).MainModule.FileName; - // goodBye.executeCommand("killserver"); - - Process.GetProcessById(Process.GetProcessById(goodBye.pID()).Parent().Id).Kill(); - Process.GetProcessById(goodBye.pID()).Kill(); - - Process.Start(info); - } - - catch (Exception E) - { - //goodBye.Log.Write("SOMETHING FUCKED UP BEYOND ALL REPAIR " + E.ToString()); - } - } - - public static int shouldRestart() - { - var curTime = DateTime.Now; - DateTime restartTime = new DateTime(curTime.Year, curTime.Month, curTime.Day, 4, 0, 0); - var a = Math.Floor((restartTime - curTime).TotalMilliseconds / 1000); - if (a > 0 && a < 2) // just in case of precision - return 0; - else - { - switch((int)a) - { - case 300: - return 300; - case 120: - return 120; - case 60: - return 60; - case 30: - return 30; - default: - return 1337; - } - } - } - - //http://stackoverflow.com/questions/2633628/can-i-get-command-line-arguments-of-other-processes-from-net-c - private static string GetCommandLine(this Process process) - { - var commandLine = new StringBuilder(); - commandLine.Append(" "); - using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id)) - { - foreach (var @object in searcher.Get()) - { - if (@object["CommandLine"].ToString().Contains("iw4m")) - commandLine.Append(@object["CommandLine"].ToString().Substring(4)); - else - commandLine.Append(@object["CommandLine"]); - commandLine.Append(" "); - } - } - - return commandLine.ToString().Trim(); - } - } - - - public static class ProcessExtensions - { - private static string FindIndexedProcessName(int pid) - { - var processName = Process.GetProcessById(pid).ProcessName; - var processesByName = Process.GetProcessesByName(processName); - string processIndexdName = null; - - for (var index = 0; index < processesByName.Length; index++) - { - processIndexdName = index == 0 ? processName : processName + "#" + index; - var processId = new PerformanceCounter("Process", "ID Process", processIndexdName); - if ((int)processId.NextValue() == pid) - { - return processIndexdName; - } - } - - return processIndexdName; - } - - private static Process FindPidFromIndexedProcessName(string indexedProcessName) - { - var parentId = new PerformanceCounter("Process", "Creating Process ID", indexedProcessName); - return Process.GetProcessById((int)parentId.NextValue()); - } - - public static Process Parent(this Process process) - { - return FindPidFromIndexedProcessName(FindIndexedProcessName(process.Id)); - } - } -} diff --git a/Chat Monitor Plugin/Chat Monitor Plugin.csproj b/Chat Monitor Plugin/Chat Monitor Plugin.csproj deleted file mode 100644 index b1912ac22..000000000 --- a/Chat Monitor Plugin/Chat Monitor Plugin.csproj +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Debug - AnyCPU - {79406C5E-A8AD-4A50-A7F0-53CE56792A31} - Library - Properties - ChatMonitor - ChatMonitor - v4.0 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {d51eeceb-438a-47da-870f-7d7b41bc24d6} - SharedLibrary - - - {99e36ebd-1fa1-494c-8a66-bece64eff378} - Webfront Plugin - - - - - copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\ChatMonitorPlugin.dll" - - - \ No newline at end of file diff --git a/Chat Monitor Plugin/Main.cs b/Chat Monitor Plugin/Main.cs deleted file mode 100644 index 343196c22..000000000 --- a/Chat Monitor Plugin/Main.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using SharedLibrary; - - -namespace ChatMonitor -{ - public class Main : IPlugin - { - - - public string Author - { - get - { - return "RaidMax"; - } - } - - public float Version - { - get - { - return 1.0f; - } - } - - public string Name - { - get - { - return "Chat Monitor Plugin"; - } - } - - - public void onLoad() - { - lastClear = DateTime.Now; - flaggedMessages = 0; - flaggedMessagesText = new List(); - } - - public void onUnload() - { - return; - } - - public void onTick(Server S) - { - return; - } - - public void onEvent(Event E, Server S) - { - - } - } -} diff --git a/IW4M Admin.sln b/IW4M Admin.sln index 5c320b596..6ed66584d 100644 --- a/IW4M Admin.sln +++ b/IW4M Admin.sln @@ -5,7 +5,6 @@ VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M ADMIN.csproj", "{DD5DCDA2-51DB-4B1A-922F-5705546E6115}" ProjectSection(ProjectDependencies) = postProject - {2321A25F-7871-47C3-8440-02551918D6A1} = {2321A25F-7871-47C3-8440-02551918D6A1} {AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {AF097E6B-48D5-4452-9CCF-0A81A21F341D} {4785AB75-66F3-4391-985D-63A5A049A0FA} = {4785AB75-66F3-4391-985D-63A5A049A0FA} {428D8EB9-ECA3-4A66-AA59-3A944378C33F} = {428D8EB9-ECA3-4A66-AA59-3A944378C33F} @@ -14,29 +13,27 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M AD {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stats Plugin", "Stats Plugin\Stats Plugin.csproj", "{4785AB75-66F3-4391-985D-63A5A049A0FA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stats Plugin", "Plugins\SimpleStats\Stats Plugin.csproj", "{4785AB75-66F3-4391-985D-63A5A049A0FA}" ProjectSection(ProjectDependencies) = postProject {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6} EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLibrary", "SharedLibrary\SharedLibrary.csproj", "{D51EECEB-438A-47DA-870F-7D7B41BC24D6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Welcome Plugin", "Welcome Plugin\Welcome Plugin.csproj", "{AF097E6B-48D5-4452-9CCF-0A81A21F341D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Welcome Plugin", "Plugins\Welcome\Welcome Plugin.csproj", "{AF097E6B-48D5-4452-9CCF-0A81A21F341D}" ProjectSection(ProjectDependencies) = postProject {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Auto Restart Plugin", "Auto Restart Plugin\Auto Restart Plugin.csproj", "{2321A25F-7871-47C3-8440-02551918D6A1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Votemap Plugin", "Plugins\VoteMap\Votemap Plugin.csproj", "{428D8EB9-ECA3-4A66-AA59-3A944378C33F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Votemap Plugin", "Votemap Plugin\Votemap Plugin.csproj", "{428D8EB9-ECA3-4A66-AA59-3A944378C33F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageboardPlugin", "Plugins\MessageBoard\MessageboardPlugin.csproj", "{E46C85BD-A99C-484E-BCCE-0F1831C5925E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageboardPlugin", "MessageboardPlugin\MessageboardPlugin.csproj", "{E46C85BD-A99C-484E-BCCE-0F1831C5925E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventAPI", "EventAPI\EventAPI.csproj", "{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventAPI", "Plugins\EventAPI\EventAPI.csproj", "{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8B310-269E-46D4-A612-24601F16065F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastRestartPlugin", "FastRestartPlugin\FastRestartPlugin.csproj", "{1479DE87-ACB5-4046-81C8-A0BA5041227D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastRestartPlugin", "Plugins\FastRestart\FastRestartPlugin.csproj", "{1479DE87-ACB5-4046-81C8-A0BA5041227D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -186,38 +183,6 @@ Global {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|x64.ActiveCfg = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|x64.Build.0 = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|x86.ActiveCfg = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Debug|x86.Build.0 = Debug|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|Any CPU.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|x64.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|x64.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|x86.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release|x86.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|x64.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|x64.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|x86.ActiveCfg = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Nightly|x86.Build.0 = Release|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU - {2321A25F-7871-47C3-8440-02551918D6A1}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.Build.0 = Debug|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -349,7 +314,6 @@ Global GlobalSection(NestedProjects) = preSolution {4785AB75-66F3-4391-985D-63A5A049A0FA} = {26E8B310-269E-46D4-A612-24601F16065F} {AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {26E8B310-269E-46D4-A612-24601F16065F} - {2321A25F-7871-47C3-8440-02551918D6A1} = {26E8B310-269E-46D4-A612-24601F16065F} {428D8EB9-ECA3-4A66-AA59-3A944378C33F} = {26E8B310-269E-46D4-A612-24601F16065F} {E46C85BD-A99C-484E-BCCE-0F1831C5925E} = {26E8B310-269E-46D4-A612-24601F16065F} {C9E821BF-23AD-4CB5-B7F9-B3B99B606650} = {26E8B310-269E-46D4-A612-24601F16065F} diff --git a/EventAPI/EventAPI.csproj b/Plugins/EventAPI/EventAPI.csproj similarity index 97% rename from EventAPI/EventAPI.csproj rename to Plugins/EventAPI/EventAPI.csproj index b9aca17dd..d14099270 100644 --- a/EventAPI/EventAPI.csproj +++ b/Plugins/EventAPI/EventAPI.csproj @@ -47,7 +47,7 @@ MinimumRecommendedRules.ruleset - + {d51eeceb-438a-47da-870f-7d7b41bc24d6} SharedLibrary False diff --git a/EventAPI/Plugin.cs b/Plugins/EventAPI/Plugin.cs similarity index 97% rename from EventAPI/Plugin.cs rename to Plugins/EventAPI/Plugin.cs index 9715adaff..190bfa00a 100644 --- a/EventAPI/Plugin.cs +++ b/Plugins/EventAPI/Plugin.cs @@ -35,7 +35,7 @@ namespace EventAPI { StringBuilder s = new StringBuilder(); foreach (var S in Events.activeServers) - s.Append(String.Format("{0} has {1}/{4} players playing {2} on {3}\n", S.getName(), S.getPlayers().Count, Utilities.gametypeLocalized(S.getGametype()), S.CurrentMap.Name, S.MaxClients)); + s.Append(String.Format("{0} has {1}/{4} players playing {2} on {3}\n", S.getName(), S.GetPlayersAsList().Count, Utilities.gametypeLocalized(S.getGametype()), S.CurrentMap.Name, S.MaxClients)); requestedEvent.Event = new RestEvent(RestEvent.eType.STATUS, RestEvent.eVersion.IW4MAdmin, s.ToString(), "Status", "", ""); requestedEvent.eventCount = 1; } diff --git a/EventAPI/packages.config b/Plugins/EventAPI/packages.config similarity index 100% rename from EventAPI/packages.config rename to Plugins/EventAPI/packages.config diff --git a/FastRestartPlugin/FastRestartPlugin.csproj b/Plugins/FastRestart/FastRestartPlugin.csproj similarity index 96% rename from FastRestartPlugin/FastRestartPlugin.csproj rename to Plugins/FastRestart/FastRestartPlugin.csproj index eadff0b04..b10db6aea 100644 --- a/FastRestartPlugin/FastRestartPlugin.csproj +++ b/Plugins/FastRestart/FastRestartPlugin.csproj @@ -42,7 +42,7 @@ - + {d51eeceb-438a-47da-870f-7d7b41bc24d6} SharedLibrary diff --git a/FastRestartPlugin/Plugin.cs b/Plugins/FastRestart/Plugin.cs similarity index 100% rename from FastRestartPlugin/Plugin.cs rename to Plugins/FastRestart/Plugin.cs diff --git a/FastRestartPlugin/Properties/AssemblyInfo.cs b/Plugins/FastRestart/Properties/AssemblyInfo.cs similarity index 100% rename from FastRestartPlugin/Properties/AssemblyInfo.cs rename to Plugins/FastRestart/Properties/AssemblyInfo.cs diff --git a/MessageboardPlugin/Encryption.cs b/Plugins/MessageBoard/Encryption.cs similarity index 100% rename from MessageboardPlugin/Encryption.cs rename to Plugins/MessageBoard/Encryption.cs diff --git a/MessageboardPlugin/Events.cs b/Plugins/MessageBoard/Events.cs similarity index 100% rename from MessageboardPlugin/Events.cs rename to Plugins/MessageBoard/Events.cs diff --git a/MessageboardPlugin/Exceptions.cs b/Plugins/MessageBoard/Exceptions.cs similarity index 100% rename from MessageboardPlugin/Exceptions.cs rename to Plugins/MessageBoard/Exceptions.cs diff --git a/MessageboardPlugin/Forum.cs b/Plugins/MessageBoard/Forum.cs similarity index 100% rename from MessageboardPlugin/Forum.cs rename to Plugins/MessageBoard/Forum.cs diff --git a/MessageboardPlugin/Identifiable.cs b/Plugins/MessageBoard/Identifiable.cs similarity index 100% rename from MessageboardPlugin/Identifiable.cs rename to Plugins/MessageBoard/Identifiable.cs diff --git a/MessageboardPlugin/MessageboardPlugin.csproj b/Plugins/MessageBoard/MessageboardPlugin.csproj similarity index 98% rename from MessageboardPlugin/MessageboardPlugin.csproj rename to Plugins/MessageBoard/MessageboardPlugin.csproj index 79ee51eaf..8732b3811 100644 --- a/MessageboardPlugin/MessageboardPlugin.csproj +++ b/Plugins/MessageBoard/MessageboardPlugin.csproj @@ -117,7 +117,7 @@ - + {d51eeceb-438a-47da-870f-7d7b41bc24d6} SharedLibrary False diff --git a/MessageboardPlugin/Plugin.cs b/Plugins/MessageBoard/Plugin.cs similarity index 100% rename from MessageboardPlugin/Plugin.cs rename to Plugins/MessageBoard/Plugin.cs diff --git a/MessageboardPlugin/Rank.cs b/Plugins/MessageBoard/Rank.cs similarity index 100% rename from MessageboardPlugin/Rank.cs rename to Plugins/MessageBoard/Rank.cs diff --git a/MessageboardPlugin/Session.cs b/Plugins/MessageBoard/Session.cs similarity index 100% rename from MessageboardPlugin/Session.cs rename to Plugins/MessageBoard/Session.cs diff --git a/MessageboardPlugin/Storage.cs b/Plugins/MessageBoard/Storage.cs similarity index 100% rename from MessageboardPlugin/Storage.cs rename to Plugins/MessageBoard/Storage.cs diff --git a/MessageboardPlugin/Thread.cs b/Plugins/MessageBoard/Thread.cs similarity index 100% rename from MessageboardPlugin/Thread.cs rename to Plugins/MessageBoard/Thread.cs diff --git a/MessageboardPlugin/User.cs b/Plugins/MessageBoard/User.cs similarity index 100% rename from MessageboardPlugin/User.cs rename to Plugins/MessageBoard/User.cs diff --git a/MessageboardPlugin/app.config b/Plugins/MessageBoard/app.config similarity index 100% rename from MessageboardPlugin/app.config rename to Plugins/MessageBoard/app.config diff --git a/MessageboardPlugin/forum/category.html b/Plugins/MessageBoard/forum/category.html similarity index 100% rename from MessageboardPlugin/forum/category.html rename to Plugins/MessageBoard/forum/category.html diff --git a/MessageboardPlugin/forum/home.html b/Plugins/MessageBoard/forum/home.html similarity index 100% rename from MessageboardPlugin/forum/home.html rename to Plugins/MessageBoard/forum/home.html diff --git a/MessageboardPlugin/forum/login.html b/Plugins/MessageBoard/forum/login.html similarity index 100% rename from MessageboardPlugin/forum/login.html rename to Plugins/MessageBoard/forum/login.html diff --git a/MessageboardPlugin/forum/postthread.html b/Plugins/MessageBoard/forum/postthread.html similarity index 100% rename from MessageboardPlugin/forum/postthread.html rename to Plugins/MessageBoard/forum/postthread.html diff --git a/MessageboardPlugin/forum/register.html b/Plugins/MessageBoard/forum/register.html similarity index 100% rename from MessageboardPlugin/forum/register.html rename to Plugins/MessageBoard/forum/register.html diff --git a/MessageboardPlugin/forum/thread.html b/Plugins/MessageBoard/forum/thread.html similarity index 100% rename from MessageboardPlugin/forum/thread.html rename to Plugins/MessageBoard/forum/thread.html diff --git a/MessageboardPlugin/forum/user.html b/Plugins/MessageBoard/forum/user.html similarity index 100% rename from MessageboardPlugin/forum/user.html rename to Plugins/MessageBoard/forum/user.html diff --git a/MessageboardPlugin/forum/usercp.html b/Plugins/MessageBoard/forum/usercp.html similarity index 100% rename from MessageboardPlugin/forum/usercp.html rename to Plugins/MessageBoard/forum/usercp.html diff --git a/MessageboardPlugin/packages.config b/Plugins/MessageBoard/packages.config similarity index 100% rename from MessageboardPlugin/packages.config rename to Plugins/MessageBoard/packages.config diff --git a/Stats Plugin/Plugin.cs b/Plugins/SimpleStats/Plugin.cs similarity index 99% rename from Stats Plugin/Plugin.cs rename to Plugins/SimpleStats/Plugin.cs index 74b5e95a4..472bde841 100644 --- a/Stats Plugin/Plugin.cs +++ b/Plugins/SimpleStats/Plugin.cs @@ -181,7 +181,7 @@ namespace StatsPlugin if (E.Type == Event.GType.MapEnd || E.Type == Event.GType.Stop) { - foreach (Player P in S.getPlayers()) + foreach (Player P in S.GetPlayersAsList()) { if (P == null) diff --git a/Stats Plugin/Properties/AssemblyInfo.cs b/Plugins/SimpleStats/Properties/AssemblyInfo.cs similarity index 100% rename from Stats Plugin/Properties/AssemblyInfo.cs rename to Plugins/SimpleStats/Properties/AssemblyInfo.cs diff --git a/Stats Plugin/Stats Plugin.csproj b/Plugins/SimpleStats/Stats Plugin.csproj similarity index 97% rename from Stats Plugin/Stats Plugin.csproj rename to Plugins/SimpleStats/Stats Plugin.csproj index bc66b1990..ee65a861f 100644 --- a/Stats Plugin/Stats Plugin.csproj +++ b/Plugins/SimpleStats/Stats Plugin.csproj @@ -58,7 +58,7 @@ - + {d51eeceb-438a-47da-870f-7d7b41bc24d6} SharedLibrary False diff --git a/Votemap Plugin/Plugin.cs b/Plugins/VoteMap/Plugin.cs similarity index 99% rename from Votemap Plugin/Plugin.cs rename to Plugins/VoteMap/Plugin.cs index 6fa00f2ad..df5a99e1c 100644 --- a/Votemap Plugin/Plugin.cs +++ b/Plugins/VoteMap/Plugin.cs @@ -266,7 +266,7 @@ namespace Votemap_Plugin MapResult m = serverVotes.getTopMap(); await S.Broadcast("Voting has ended!"); - if (m.voteNum < minVotes && S.getPlayers().Count > 4) + if (m.voteNum < minVotes && S.GetPlayersAsList().Count > 4) await S.Broadcast("Vote map failed. At least ^5" + minVotes + " ^7people must choose the same map"); else { diff --git a/Votemap Plugin/Votemap Plugin.csproj b/Plugins/VoteMap/Votemap Plugin.csproj similarity index 97% rename from Votemap Plugin/Votemap Plugin.csproj rename to Plugins/VoteMap/Votemap Plugin.csproj index 57b187376..d264ab167 100644 --- a/Votemap Plugin/Votemap Plugin.csproj +++ b/Plugins/VoteMap/Votemap Plugin.csproj @@ -47,7 +47,7 @@ MinimumRecommendedRules.ruleset - + {d51eeceb-438a-47da-870f-7d7b41bc24d6} SharedLibrary False diff --git a/Welcome Plugin/CountryLookup.cs b/Plugins/Welcome/CountryLookup.cs similarity index 100% rename from Welcome Plugin/CountryLookup.cs rename to Plugins/Welcome/CountryLookup.cs diff --git a/Welcome Plugin/GeoIP.dat b/Plugins/Welcome/GeoIP.dat similarity index 100% rename from Welcome Plugin/GeoIP.dat rename to Plugins/Welcome/GeoIP.dat diff --git a/Welcome Plugin/Plugin.cs b/Plugins/Welcome/Plugin.cs similarity index 100% rename from Welcome Plugin/Plugin.cs rename to Plugins/Welcome/Plugin.cs diff --git a/Welcome Plugin/Properties/AssemblyInfo.cs b/Plugins/Welcome/Properties/AssemblyInfo.cs similarity index 100% rename from Welcome Plugin/Properties/AssemblyInfo.cs rename to Plugins/Welcome/Properties/AssemblyInfo.cs diff --git a/Welcome Plugin/Welcome Plugin.csproj b/Plugins/Welcome/Welcome Plugin.csproj similarity index 98% rename from Welcome Plugin/Welcome Plugin.csproj rename to Plugins/Welcome/Welcome Plugin.csproj index 436f8c28b..7c95fae10 100644 --- a/Welcome Plugin/Welcome Plugin.csproj +++ b/Plugins/Welcome/Welcome Plugin.csproj @@ -63,7 +63,7 @@ - + {d51eeceb-438a-47da-870f-7d7b41bc24d6} SharedLibrary False diff --git a/Welcome Plugin/packages.config b/Plugins/Welcome/packages.config similarity index 100% rename from Welcome Plugin/packages.config rename to Plugins/Welcome/packages.config diff --git a/SharedLibrary/Commands/NativeCommands.cs b/SharedLibrary/Commands/NativeCommands.cs index 2d7dd24f7..d1e18659b 100644 --- a/SharedLibrary/Commands/NativeCommands.cs +++ b/SharedLibrary/Commands/NativeCommands.cs @@ -171,7 +171,7 @@ namespace SharedLibrary.Commands else playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.levelToColor(P.Level), P.ClientID, P.Name, SharedLibrary.Utilities.getSpaces(Player.Permission.SeniorAdmin.ToString().Length - P.Level.ToString().Length)); - if (count == 2 || E.Owner.getPlayers().Count == 1) + if (count == 2 || E.Owner.GetPlayersAsList().Count == 1) { await E.Origin.Tell(playerList.ToString()); count = 0; @@ -293,7 +293,7 @@ namespace SharedLibrary.Commands // todo: manager DB foreach (var server in E.Owner.Manager.GetServers()) { - foreach (var player in server.getPlayers()) + foreach (var player in server.GetPlayersAsList()) { if (player != null && player.NetworkID == E.Target.NetworkID) { @@ -624,7 +624,6 @@ namespace SharedLibrary.Commands var B = E.Owner.Manager.GetClientPenalties().FindPenalties(E.Target); var BannedPenalty = B.Find(b => b.BType == Penalty.Type.Ban); - if (BannedPenalty == null) { await E.Origin.Tell("No active ban was found for that player."); diff --git a/SharedLibrary/Database.cs b/SharedLibrary/Database.cs index 4b971cda3..47d013bed 100644 --- a/SharedLibrary/Database.cs +++ b/SharedLibrary/Database.cs @@ -384,7 +384,7 @@ namespace SharedLibrary var Con = GetNewConnection(); SQLiteCommand cmd = new SQLiteCommand(Con) { - CommandText = "SELECT * FROM CLIENTS WHERE Name LIKE @Name LIMIT 32" + CommandText = "SELECT * FROM CLIENTS WHERE Name LIKE @Name" }; cmd.Parameters.AddWithValue("@Name", '%' + name + '%'); diff --git a/SharedLibrary/Server.cs b/SharedLibrary/Server.cs index 519395062..16f9bfd61 100644 --- a/SharedLibrary/Server.cs +++ b/SharedLibrary/Server.cs @@ -27,7 +27,7 @@ namespace SharedLibrary events = new Queue(); Reports = new List(); playerHistory = new Queue(); - chatHistory = new List(); + ChatHistory = new List(); lastWebChat = DateTime.Now; nextMessage = 0; initMacros(); @@ -96,24 +96,13 @@ namespace SharedLibrary return Port; } - //Returns number of active clients on server -- *INT* - public int getNumPlayers() - { - return ClientNum; - } - //Returns list of all current players - public List getPlayers() + public List GetPlayersAsList() { return Players.FindAll(x => x != null); } - public int pID() - { - return this.PID; - } - /// /// Get any know aliases ( name or ip based ) from the database /// @@ -159,7 +148,7 @@ namespace SharedLibrary /// Matching player if found public Player GetClientByName(String pName) { - return Players.FirstOrDefault(p => p.Name.ToLower() == pName.ToLower()); + return Players.FirstOrDefault(p => p != null && p.Name.ToLower() == pName.ToLower()); } /// @@ -209,7 +198,7 @@ namespace SharedLibrary public async Task Broadcast(String Message) { #if DEBUG - // return; + return; #endif await this.ExecuteCommandAsync($"sayraw {Message}"); } @@ -222,8 +211,8 @@ namespace SharedLibrary public async Task Tell(String Message, Player Target) { #if DEBUG - //if (!Target.lastEvent.Remote) - // return; + if (!Target.lastEvent.Remote) + return; #endif if (Target.ClientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote) await this.ExecuteCommandAsync($"tellraw {Target.ClientID} {Message}^7"); @@ -308,13 +297,11 @@ namespace SharedLibrary if ((requestTime - lastWebChat).TotalSeconds > 1) { Broadcast("^1[WEBCHAT] ^5" + P.Name + "^7 - " + Message); - while (chatHistory.Count > Math.Ceiling((double)ClientNum / 2)) - chatHistory.RemoveAt(0); if (Message.Length > 50) Message = Message.Substring(0, 50) + "..."; - chatHistory.Add(new Chat(P.Name, Utilities.StripColors(Message), DateTime.Now)); + ChatHistory.Add(new Chat(P.Name, Utilities.StripColors(Message), DateTime.Now)); lastWebChat = DateTime.Now; } } @@ -432,7 +419,7 @@ namespace SharedLibrary public String Gametype; public int totalKills = 0; public List Reports; - public List chatHistory; + public List ChatHistory; public Queue playerHistory { get; private set; } //Info @@ -452,8 +439,6 @@ namespace SharedLibrary protected DateTime lastWebChat; public string Password { get; private set; } - public int Handle { get; private set; } - protected int PID; protected IFile logFile; // Log stuff