Merge pull request #3332 from PEMapModder/dec

Disallow registration of events without handlerList, fixes #3330
This commit is contained in:
Michael Yoo 2015-08-11 16:12:59 +09:30
commit ff232a9f04

View File

@ -748,8 +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) or (new \ReflectionClass($event))->isAbstract()){
throw new PluginException($event . " is not a valid Event");
if(!is_subclass_of($event, Event::class)){
throw new PluginException($event . " is not an Event");
}
$class = new \ReflectionClass($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()){