mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
-added back player history graphs (past 12 hours every 15 minutes)
-fixed issue with configurationmanager files and threading -servers on webfront listed in descending player count -fixed resolution of tempban times from console feedback -Added tests plugin to simulate functionality
This commit is contained in:
78
Plugins/Tests/Plugin.cs
Normal file
78
Plugins/Tests/Plugin.cs
Normal file
@ -0,0 +1,78 @@
|
||||
#if DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharedLibrary;
|
||||
using SharedLibrary.Interfaces;
|
||||
using SharedLibrary.Helpers;
|
||||
|
||||
namespace IW4MAdmin.Plugins
|
||||
{
|
||||
public class Tests : IPlugin
|
||||
{
|
||||
public string Name => "Dev Tests";
|
||||
|
||||
public float Version => 0.1f;
|
||||
|
||||
public string Author => "RaidMax";
|
||||
|
||||
private static DateTime Interval;
|
||||
|
||||
public async Task OnEventAsync(Event E, Server S)
|
||||
{
|
||||
if (E.Type == Event.GType.Start)
|
||||
{
|
||||
#region PLAYER_HISTORY
|
||||
var rand = new Random(GetHashCode());
|
||||
var time = DateTime.UtcNow;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (S.PlayerHistory.Count > 0)
|
||||
return;
|
||||
|
||||
while (S.PlayerHistory.Count < 48)
|
||||
{
|
||||
S.PlayerHistory.Enqueue(new PlayerHistory(time, rand.Next(7, 18)));
|
||||
time = time.AddMinutes(15);
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnLoadAsync()
|
||||
{
|
||||
Interval = DateTime.Now;
|
||||
}
|
||||
|
||||
public async Task OnTickAsync(Server S)
|
||||
{
|
||||
if ((DateTime.Now - Interval).TotalSeconds > 5)
|
||||
{
|
||||
var rand = new Random();
|
||||
int index = rand.Next(0, 17);
|
||||
var p = new Player($"Test_{index}", "_test", index, (int)Player.Permission.User)
|
||||
{
|
||||
Ping = 1
|
||||
};
|
||||
|
||||
p.SetIP("127.0.0.1");
|
||||
|
||||
if (S.Players.ElementAt(index) != null)
|
||||
await S.RemovePlayer(index);
|
||||
await S.AddPlayer(p);
|
||||
|
||||
Interval = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnUnloadAsync()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
36
Plugins/Tests/Properties/AssemblyInfo.cs
Normal file
36
Plugins/Tests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b8c2a759-8663-4f6f-9ba4-19595f5e12c1")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
56
Plugins/Tests/Tests.csproj
Normal file
56
Plugins/Tests/Tests.csproj
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Tests</RootNamespace>
|
||||
<AssemblyName>Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</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>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Plugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
|
||||
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
|
||||
<Name>SharedLibrary</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user