Moved plugins to a seperate folder

Uncapped the search result limit for !find
This commit is contained in:
RaidMax 2017-06-07 19:59:59 -05:00
parent 11d37d4cd6
commit 25b3e3abc1
51 changed files with 42 additions and 502 deletions

View File

@ -155,11 +155,6 @@ namespace IW4MAdmin
Players[NewPlayer.ClientID] = NewPlayer; Players[NewPlayer.ClientID] = NewPlayer;
Logger.WriteInfo($"Client {NewPlayer.Name}::{NewPlayer.NetworkID} connecting..."); // they're clean 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, "<i>CONNECTED</i>", DateTime.Now));
if (NewPlayer.Level > Player.Permission.Moderator) if (NewPlayer.Level > Player.Permission.Moderator)
await NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!"); await NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!");
@ -189,8 +184,6 @@ namespace IW4MAdmin
Players[cNum] = null; Players[cNum] = null;
ClientNum--; ClientNum--;
if (ClientNum == 0)
chatHistory.Clear();
} }
} }
@ -533,17 +526,22 @@ namespace IW4MAdmin
//Process any server event //Process any server event
override protected async Task ProcessEvent(Event E) 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) if (E.Type == Event.GType.Connect)
{ {
ChatHistory.Add(new Chat(E.Origin.Name, "<i>CONNECTED</i>", DateTime.Now));
return; return;
} }
if (E.Type == Event.GType.Disconnect) if (E.Type == Event.GType.Disconnect)
{ {
ChatHistory.Add(new Chat(E.Origin.Name, "<i>DISCONNECTED</i>", DateTime.Now));
while (chatHistory.Count > Math.Ceiling(((double)ClientNum - 1) / 2)) if (ClientNum == 0)
chatHistory.RemoveAt(0); ChatHistory.Clear();
chatHistory.Add(new Chat(E.Origin.Name, "<i>DISCONNECTED</i>", DateTime.Now));
return; return;
} }
@ -621,10 +619,8 @@ namespace IW4MAdmin
E.Data = E.Data.StripColors().CleanChars(); E.Data = E.Data.StripColors().CleanChars();
if (E.Data.Length > 50) if (E.Data.Length > 50)
E.Data = E.Data.Substring(0, 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; return;
} }
@ -707,9 +703,9 @@ namespace IW4MAdmin
// banned from all servers if active // banned from all servers if active
foreach (var server in Manager.GetServers()) 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) if (activeClient != null)
await server.ExecuteCommandAsync("tempbanclient " + activeClient.ClientID + " \"" + Message + "^7" + GetWebsiteString() + "^7\""); await server.ExecuteCommandAsync("tempbanclient " + activeClient.ClientID + " \"" + Message + "^7" + GetWebsiteString() + "^7\"");
} }

View File

@ -54,7 +54,6 @@ namespace IW4MAdmin
catch (Exception e) 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.maxPlayers = S.MaxClients;
eachServer.mapName = S.CurrentMap.Alias; eachServer.mapName = S.CurrentMap.Alias;
eachServer.gameType = Utilities.gametypeLocalized(S.getGametype()); eachServer.gameType = Utilities.gametypeLocalized(S.getGametype());
eachServer.currentPlayers = S.getPlayers().Count; eachServer.currentPlayers = S.GetPlayersAsList().Count;
eachServer.chatHistory = S.chatHistory; eachServer.chatHistory = S.ChatHistory;
eachServer.players = new List<PlayerInfo>(); eachServer.players = new List<PlayerInfo>();
foreach (Player P in S.getPlayers()) foreach (Player P in S.GetPlayersAsList())
{ {
PlayerInfo pInfo = new PlayerInfo(); PlayerInfo pInfo = new PlayerInfo();
pInfo.playerID = P.DatabaseID; pInfo.playerID = P.DatabaseID;

Binary file not shown.

View File

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2321A25F-7871-47C3-8440-02551918D6A1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Auto_Restart_Plugin</RootNamespace>
<AssemblyName>AutorestartPlugin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Management" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="Monitoring.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\bin\$(ConfigurationName)\plugins\AutoRestartPlugin.dll"
copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

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

View File

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

View File

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{79406C5E-A8AD-4A50-A7F0-53CE56792A31}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChatMonitor</RootNamespace>
<AssemblyName>ChatMonitor</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Include="Main.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\Webfront Plugin\Webfront Plugin.csproj">
<Project>{99e36ebd-1fa1-494c-8a66-bece64eff378}</Project>
<Name>Webfront Plugin</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\ChatMonitorPlugin.dll"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -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<string>();
}
public void onUnload()
{
return;
}
public void onTick(Server S)
{
return;
}
public void onEvent(Event E, Server S)
{
}
}
}

View File

@ -5,7 +5,6 @@ VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M ADMIN.csproj", "{DD5DCDA2-51DB-4B1A-922F-5705546E6115}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IW4M ADMIN", "Admin\IW4M ADMIN.csproj", "{DD5DCDA2-51DB-4B1A-922F-5705546E6115}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{2321A25F-7871-47C3-8440-02551918D6A1} = {2321A25F-7871-47C3-8440-02551918D6A1}
{AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {AF097E6B-48D5-4452-9CCF-0A81A21F341D} {AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {AF097E6B-48D5-4452-9CCF-0A81A21F341D}
{4785AB75-66F3-4391-985D-63A5A049A0FA} = {4785AB75-66F3-4391-985D-63A5A049A0FA} {4785AB75-66F3-4391-985D-63A5A049A0FA} = {4785AB75-66F3-4391-985D-63A5A049A0FA}
{428D8EB9-ECA3-4A66-AA59-3A944378C33F} = {428D8EB9-ECA3-4A66-AA59-3A944378C33F} {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} {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection EndProjectSection
EndProject 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 ProjectSection(ProjectDependencies) = postProject
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6} {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLibrary", "SharedLibrary\SharedLibrary.csproj", "{D51EECEB-438A-47DA-870F-7D7B41BC24D6}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLibrary", "SharedLibrary\SharedLibrary.csproj", "{D51EECEB-438A-47DA-870F-7D7B41BC24D6}"
EndProject 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 ProjectSection(ProjectDependencies) = postProject
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6} {D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection EndProjectSection
EndProject 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 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 EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageboardPlugin", "MessageboardPlugin\MessageboardPlugin.csproj", "{E46C85BD-A99C-484E-BCCE-0F1831C5925E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventAPI", "Plugins\EventAPI\EventAPI.csproj", "{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventAPI", "EventAPI\EventAPI.csproj", "{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8B310-269E-46D4-A612-24601F16065F}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8B310-269E-46D4-A612-24601F16065F}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution 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|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.ActiveCfg = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.Build.0 = 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.ActiveCfg = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.Build.0 = 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 {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -349,7 +314,6 @@ Global
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{4785AB75-66F3-4391-985D-63A5A049A0FA} = {26E8B310-269E-46D4-A612-24601F16065F} {4785AB75-66F3-4391-985D-63A5A049A0FA} = {26E8B310-269E-46D4-A612-24601F16065F}
{AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {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} {428D8EB9-ECA3-4A66-AA59-3A944378C33F} = {26E8B310-269E-46D4-A612-24601F16065F}
{E46C85BD-A99C-484E-BCCE-0F1831C5925E} = {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} {C9E821BF-23AD-4CB5-B7F9-B3B99B606650} = {26E8B310-269E-46D4-A612-24601F16065F}

View File

@ -47,7 +47,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj"> <ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project> <Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name> <Name>SharedLibrary</Name>
<Private>False</Private> <Private>False</Private>

View File

@ -35,7 +35,7 @@ namespace EventAPI
{ {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
foreach (var S in Events.activeServers) 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.Event = new RestEvent(RestEvent.eType.STATUS, RestEvent.eVersion.IW4MAdmin, s.ToString(), "Status", "", "");
requestedEvent.eventCount = 1; requestedEvent.eventCount = 1;
} }

View File

@ -42,7 +42,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj"> <ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project> <Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name> <Name>SharedLibrary</Name>
</ProjectReference> </ProjectReference>

View File

@ -117,7 +117,7 @@
<WCFMetadata Include="Service References\" /> <WCFMetadata Include="Service References\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj"> <ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project> <Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name> <Name>SharedLibrary</Name>
<Private>False</Private> <Private>False</Private>

View File

@ -181,7 +181,7 @@ namespace StatsPlugin
if (E.Type == Event.GType.MapEnd || E.Type == Event.GType.Stop) 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) if (P == null)

View File

@ -58,7 +58,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj"> <ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project> <Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name> <Name>SharedLibrary</Name>
<Private>False</Private> <Private>False</Private>

View File

@ -266,7 +266,7 @@ namespace Votemap_Plugin
MapResult m = serverVotes.getTopMap(); MapResult m = serverVotes.getTopMap();
await S.Broadcast("Voting has ended!"); 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"); await S.Broadcast("Vote map failed. At least ^5" + minVotes + " ^7people must choose the same map");
else else
{ {

View File

@ -47,7 +47,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj"> <ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project> <Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name> <Name>SharedLibrary</Name>
<Private>False</Private> <Private>False</Private>

View File

@ -63,7 +63,7 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj"> <ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project> <Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name> <Name>SharedLibrary</Name>
<Private>False</Private> <Private>False</Private>

View File

@ -171,7 +171,7 @@ namespace SharedLibrary.Commands
else 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)); 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()); await E.Origin.Tell(playerList.ToString());
count = 0; count = 0;
@ -293,7 +293,7 @@ namespace SharedLibrary.Commands
// todo: manager DB // todo: manager DB
foreach (var server in E.Owner.Manager.GetServers()) 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) 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 B = E.Owner.Manager.GetClientPenalties().FindPenalties(E.Target);
var BannedPenalty = B.Find(b => b.BType == Penalty.Type.Ban); var BannedPenalty = B.Find(b => b.BType == Penalty.Type.Ban);
if (BannedPenalty == null) if (BannedPenalty == null)
{ {
await E.Origin.Tell("No active ban was found for that player."); await E.Origin.Tell("No active ban was found for that player.");

View File

@ -384,7 +384,7 @@ namespace SharedLibrary
var Con = GetNewConnection(); var Con = GetNewConnection();
SQLiteCommand cmd = new SQLiteCommand(Con) 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 + '%'); cmd.Parameters.AddWithValue("@Name", '%' + name + '%');

View File

@ -27,7 +27,7 @@ namespace SharedLibrary
events = new Queue<Event>(); events = new Queue<Event>();
Reports = new List<Report>(); Reports = new List<Report>();
playerHistory = new Queue<PlayerHistory>(); playerHistory = new Queue<PlayerHistory>();
chatHistory = new List<Chat>(); ChatHistory = new List<Chat>();
lastWebChat = DateTime.Now; lastWebChat = DateTime.Now;
nextMessage = 0; nextMessage = 0;
initMacros(); initMacros();
@ -96,24 +96,13 @@ namespace SharedLibrary
return Port; return Port;
} }
//Returns number of active clients on server -- *INT*
public int getNumPlayers()
{
return ClientNum;
}
//Returns list of all current players //Returns list of all current players
public List<Player> getPlayers() public List<Player> GetPlayersAsList()
{ {
return Players.FindAll(x => x != null); return Players.FindAll(x => x != null);
} }
public int pID()
{
return this.PID;
}
/// <summary> /// <summary>
/// Get any know aliases ( name or ip based ) from the database /// Get any know aliases ( name or ip based ) from the database
/// </summary> /// </summary>
@ -159,7 +148,7 @@ namespace SharedLibrary
/// <returns>Matching player if found</returns> /// <returns>Matching player if found</returns>
public Player GetClientByName(String pName) 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());
} }
/// <summary> /// <summary>
@ -209,7 +198,7 @@ namespace SharedLibrary
public async Task Broadcast(String Message) public async Task Broadcast(String Message)
{ {
#if DEBUG #if DEBUG
// return; return;
#endif #endif
await this.ExecuteCommandAsync($"sayraw {Message}"); await this.ExecuteCommandAsync($"sayraw {Message}");
} }
@ -222,8 +211,8 @@ namespace SharedLibrary
public async Task Tell(String Message, Player Target) public async Task Tell(String Message, Player Target)
{ {
#if DEBUG #if DEBUG
//if (!Target.lastEvent.Remote) if (!Target.lastEvent.Remote)
// return; return;
#endif #endif
if (Target.ClientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote) if (Target.ClientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote)
await this.ExecuteCommandAsync($"tellraw {Target.ClientID} {Message}^7"); await this.ExecuteCommandAsync($"tellraw {Target.ClientID} {Message}^7");
@ -308,13 +297,11 @@ namespace SharedLibrary
if ((requestTime - lastWebChat).TotalSeconds > 1) if ((requestTime - lastWebChat).TotalSeconds > 1)
{ {
Broadcast("^1[WEBCHAT] ^5" + P.Name + "^7 - " + Message); Broadcast("^1[WEBCHAT] ^5" + P.Name + "^7 - " + Message);
while (chatHistory.Count > Math.Ceiling((double)ClientNum / 2))
chatHistory.RemoveAt(0);
if (Message.Length > 50) if (Message.Length > 50)
Message = Message.Substring(0, 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; lastWebChat = DateTime.Now;
} }
} }
@ -432,7 +419,7 @@ namespace SharedLibrary
public String Gametype; public String Gametype;
public int totalKills = 0; public int totalKills = 0;
public List<Report> Reports; public List<Report> Reports;
public List<Chat> chatHistory; public List<Chat> ChatHistory;
public Queue<PlayerHistory> playerHistory { get; private set; } public Queue<PlayerHistory> playerHistory { get; private set; }
//Info //Info
@ -452,8 +439,6 @@ namespace SharedLibrary
protected DateTime lastWebChat; protected DateTime lastWebChat;
public string Password { get; private set; } public string Password { get; private set; }
public int Handle { get; private set; }
protected int PID;
protected IFile logFile; protected IFile logFile;
// Log stuff // Log stuff