From 9610c55b1931da8ec24ae0bb2a3829532950dc1e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Jul 2018 16:59:33 +0100 Subject: [PATCH 1/3] PluginManager: Skip methods not declared by instanceof Listener when registering handlers (#2293) This is quite an interesting bug. If you have ```php class A{ public function onMove(PlayerMoveEvent $event){} //shouldn't be a handler because this class isn't a Listener } class B extends A implements Listener{} ``` then ```php registerEvents(new B, $plugin); ``` then `A::onMove()` will be registered as an event handler even though `A` is not an instanceof `Listener`. This was observed by noting that plugins which do something like `extends PluginBase implements Listener` causes `registerEvents()` to try and register `PluginBase` methods as event handlers, which could lead to astonishing behaviour. then A::onMove() will be registered as an event handler even though A is not an instanceof Listener. This was observed by noting that plugins which do something like "extends PluginBase implements Listener" causes registerEvents() to try and register PluginBase methods as event handlers, which could lead to astonishing behaviour. --- src/pocketmine/plugin/PluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index a709e253d..009afc86d 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -783,7 +783,7 @@ class PluginManager{ $reflection = new \ReflectionClass(get_class($listener)); foreach($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method){ - if(!$method->isStatic()){ + if(!$method->isStatic() and $method->getDeclaringClass()->implementsInterface(Listener::class)){ $tags = Utils::parseDocComment((string) $method->getDocComment()); if(isset($tags["notHandler"])){ continue; From ce9f18c6b425ac0375df1a755e1ba6eac53a1c58 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Jul 2018 17:38:40 +0100 Subject: [PATCH 2/3] disable dev flag --- src/pocketmine/PocketMine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 65246df5f..7c02671e3 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -38,7 +38,7 @@ namespace pocketmine { const NAME = "PocketMine-MP"; const BASE_VERSION = "3.0.6"; - const IS_DEVELOPMENT_BUILD = true; + const IS_DEVELOPMENT_BUILD = false; const BUILD_NUMBER = 0; const MIN_PHP_VERSION = "7.2.0"; From b3ffce9729b83d387581d7ca97bec70cb46228af Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Jul 2018 09:14:38 +0100 Subject: [PATCH 3/3] back to dev --- src/pocketmine/PocketMine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 7c02671e3..6a4494474 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -37,8 +37,8 @@ namespace pocketmine { use pocketmine\wizard\SetupWizard; const NAME = "PocketMine-MP"; - const BASE_VERSION = "3.0.6"; - const IS_DEVELOPMENT_BUILD = false; + const BASE_VERSION = "3.0.7"; + const IS_DEVELOPMENT_BUILD = true; const BUILD_NUMBER = 0; const MIN_PHP_VERSION = "7.2.0";