From 4b2cb566efc45572dc03d5428668e85007c8f7af Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 23 Mar 2024 23:08:52 +0000 Subject: [PATCH] feat: simplify the registration of event handlers --- include/example_plugin.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/example_plugin.h b/include/example_plugin.h index 6d84532..c7ffb59 100644 --- a/include/example_plugin.h +++ b/include/example_plugin.h @@ -27,12 +27,11 @@ class ExamplePlugin : public endstone::Plugin { } // You can register an event handler directly in the Plugin class. - registerEventHandler(&ExamplePlugin::onServerLoad, *this); + registerEvent(&ExamplePlugin::onServerLoad, *this); // You can also create a separate class (e.g. ExampleListener) and register the event handler from that class. listener_ = std::make_unique(*this); - registerEventHandler(&ExampleListener::onServerLoad, *listener_, - endstone::EventPriority::HIGH); + registerEvent(&ExampleListener::onServerLoad, *listener_, endstone::EventPriority::High); } void onDisable() override @@ -60,7 +59,7 @@ class ExamplePlugin : public endstone::Plugin { void onServerLoad(endstone::ServerLoadEvent &event) { - getLogger().info("ServerLoadEvent is passed to ExamplePlugin::onServerLoad"); + getLogger().info("{} is passed to ExamplePlugin::onServerLoad", event.getEventName()); } private: