From ff16f2ef05704fcb9cfedd96094f9343db257a4c Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Wed, 29 Jul 2015 21:47:39 -0400 Subject: [PATCH 1/2] Disallow registration of events without handlerList --- src/pocketmine/plugin/PluginManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index c01cc6aaf..eaa40dd90 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -748,7 +748,8 @@ class PluginManager{ * @throws PluginException */ public function registerEvent($event, Listener $listener, $priority, EventExecutor $executor, Plugin $plugin, $ignoreCancelled = false){ - if(!is_subclass_of($event, Event::class) or (new \ReflectionClass($event))->isAbstract()){ + $class = new \ReflectionClass($event); + if(!is_subclass_of($event, Event::class) or $class->isAbstract() or $class->getProperty("handlerList")->getDeclaringClass()->getName() !== $event){ throw new PluginException($event . " is not a valid Event"); } From d5c27029086fbdcd49a56564f9ea8055e5cdf310 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Mon, 10 Aug 2015 22:14:11 +0800 Subject: [PATCH 2/2] Update PluginManager.php --- src/pocketmine/plugin/PluginManager.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index eaa40dd90..5c746cb16 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -748,9 +748,15 @@ class PluginManager{ * @throws PluginException */ public function registerEvent($event, Listener $listener, $priority, EventExecutor $executor, Plugin $plugin, $ignoreCancelled = false){ + if(!is_subclass_of($event, Event::class)){ + throw new PluginException($event . " is not an Event"); + } $class = new \ReflectionClass($event); - if(!is_subclass_of($event, Event::class) or $class->isAbstract() or $class->getProperty("handlerList")->getDeclaringClass()->getName() !== $event){ - throw new PluginException($event . " is not a valid Event"); + if($class->isAbstract()){ + throw new PluginException($event . " is an abstract Event"); + } + if($class->getProperty("handlerList")->getDeclaringClass()->getName() !== $event){ + throw new PluginException($event . " does not have a handler list"); } if(!$plugin->isEnabled()){