From c1d2455e4d84ac2ae980b32e5429d2216228074c Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Sun, 8 Dec 2024 15:20:11 -0500 Subject: [PATCH] improve example --- MiraAPI.Example/ExampleEventHandlers.cs | 8 ++++++++ MiraAPI.Example/ExamplePlugin.cs | 16 ---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/MiraAPI.Example/ExampleEventHandlers.cs b/MiraAPI.Example/ExampleEventHandlers.cs index e8b2c80..03eb2d4 100644 --- a/MiraAPI.Example/ExampleEventHandlers.cs +++ b/MiraAPI.Example/ExampleEventHandlers.cs @@ -11,6 +11,7 @@ public static void Initialize() { // Register event handlers here MiraEventManager.RegisterEventHandler>(FreezeButtonClickHandler, 1); + MiraEventManager.RegisterEventHandler>(FreezeButtonCancelledHandler); } // Example event handler @@ -24,4 +25,11 @@ public static void FreezeButtonClickHandler(MiraButtonClickEvent @ @event.Button.SetTimer(15f); } } + + // Example event handler + public static void FreezeButtonCancelledHandler(MiraButtonCancelledEvent @event) + { + Logger.Warning("Freeze button cancelled!"); + @event.Button.OverrideName("Freeze Canceled"); + } } diff --git a/MiraAPI.Example/ExamplePlugin.cs b/MiraAPI.Example/ExamplePlugin.cs index 6740f22..be16a94 100644 --- a/MiraAPI.Example/ExamplePlugin.cs +++ b/MiraAPI.Example/ExamplePlugin.cs @@ -25,22 +25,6 @@ public partial class ExamplePlugin : BasePlugin, IMiraPlugin public ConfigFile GetConfigFile() => Config; public override void Load() { - MiraEventManager.RegisterEventHandler>(e=> - { - Logger.Warning("Freeze button clicked!"); - - if (PlayerControl.LocalPlayer.Data.PlayerName == "stupid") - { - e.Cancel(); - e.Button.SetTimer(15f); - } - }); - - MiraEventManager.RegisterEventHandler>(e=> - { - Logger.Warning("Freeze button cancelled!"); - e.Button.OverrideName("Freeze Canceled"); - }); Harmony.PatchAll(); } }