IW4M-Admin/Plugins/LiveRadar/Plugin.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2019-06-30 14:37:59 -04:00
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace LiveRadar
{
public class Plugin : IPlugin
{
public string Name => "Live Radar";
public float Version => (float)Utilities.GetVersionAsDouble();
public string Author => "RaidMax";
public Task OnEventAsync(GameEvent E, Server S)
{
if (E.Type == GameEvent.EventType.Unknown)
{
if (E.Data?.StartsWith("LiveRadar") ?? false)
{
var radarUpdate = RadarEvent.Parse(E.Data);
var client = S.GetClientsAsList().First(_client => _client.NetworkId == radarUpdate.Guid);
radarUpdate.Name = client.Name;
client.SetAdditionalProperty("LiveRadar", radarUpdate);
}
}
return Task.CompletedTask;
}
public Task OnLoadAsync(IManager manager)
{
return Task.CompletedTask;
}
public Task OnTickAsync(Server S)
{
return Task.CompletedTask;
}
public Task OnUnloadAsync()
{
return Task.CompletedTask;
}
}
}