From 7565b786e76806886139811d0d63c66198b039a8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 4 May 2018 21:36:58 +0100 Subject: [PATCH] Implemented @notHandler annotation for event handlers - skip registering any handlers with this annotation (#2164) It is somewhat reasonable to have a function in an event handler which accepts an Event parameter, but is not a handler. For example, multiple event handlers can redirect to the same function to process an event, but this function may not want to receive called events. There are other ways to get around this, such as making the event handler protected/private, or adding a dummy parameter, but this way is cleaner and more explicit. Relevant old-repo PR: PocketMine/PocketMine-MP#2143 --- src/pocketmine/plugin/PluginManager.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index db9b490a47..4dfac77214 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -744,6 +744,9 @@ class PluginManager{ foreach($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method){ if(!$method->isStatic()){ $tags = self::parseDocComment((string) $method->getDocComment()); + if(isset($tags["notHandler"])){ + continue; + } try{ $priority = isset($tags["priority"]) ? EventPriority::fromString($tags["priority"]) : EventPriority::NORMAL;