IW4M-Admin/Plugins/Tests/Plugin.cs
RaidMax 8d52d7ddc5 -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
2017-09-27 15:07:43 -05:00

78 lines
1.9 KiB
C#

#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