From bc6daf26d783e2fb2850486f5357ee7ddd46311f Mon Sep 17 00:00:00 2001 From: Killers0992 <38152961+Killers0992@users.noreply.github.com> Date: Wed, 21 Sep 2022 22:06:37 +0200 Subject: [PATCH] Fix registering events, add missing parameters in template plugin (#18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add analyzers * Add analyzers * Added more advanced event cancellation. * Fix * Added manual handling of preauth event * Update API * Fix registering events and add missing parameters Co-authored-by: Ɓukasz Jurczyk --- NwPluginAPI/Events/EventManager.cs | 2 +- TemplatePlugin/MainClass.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NwPluginAPI/Events/EventManager.cs b/NwPluginAPI/Events/EventManager.cs index 692c796..d255e10 100644 --- a/NwPluginAPI/Events/EventManager.cs +++ b/NwPluginAPI/Events/EventManager.cs @@ -246,7 +246,7 @@ private static bool ValidateEvent(Type[] parameters, Type[] requiredParameters) public static void RegisterEvents(object plugin) { Type type = plugin.GetType(); - RegisterEvents(type, type); + RegisterEvents(type, plugin); } /// diff --git a/TemplatePlugin/MainClass.cs b/TemplatePlugin/MainClass.cs index 0d6e44f..4b0078d 100644 --- a/TemplatePlugin/MainClass.cs +++ b/TemplatePlugin/MainClass.cs @@ -6,6 +6,7 @@ using InventorySystem.Items.Firearms; using InventorySystem.Items.Radio; using InventorySystem.Items.Usables; + using LiteNetLib; using MapGeneration.Distributors; using PlayerRoles; using PlayerStatsSystem; @@ -14,6 +15,7 @@ using PluginAPI.Core.Interfaces; using PluginAPI.Enums; using PluginAPI.Events; + using System; using TemplatePlugin.Factory; using ItemPickupBase = InventorySystem.Items.Pickups.ItemPickupBase; @@ -254,7 +256,7 @@ void OnPlayerPickupScp330(MyPlayer plr, ItemPickupBase pickup) } [PluginEvent(ServerEventType.PlayerPreauth)] - void OnPreauth(string userid, string ipAddress, long expiration, CentralAuthPreauthFlags flags, string country, byte[] signature) + void OnPreauth(string userid, string ipAddress, long expiration, CentralAuthPreauthFlags flags, string country, byte[] signature, ConnectionRequest req, Int32 index) { Log.Info($"Player &6{userid}&r (&6{ipAddress}&r) preauthenticated from country &6{country}&r with central flags &6{flags}&r"); }