From ff16f2ef05704fcb9cfedd96094f9343db257a4c Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Wed, 29 Jul 2015 21:47:39 -0400 Subject: [PATCH 1/5] 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/5] 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()){ From a5efd0bdf8fd589a295914b6e105b8a80abd446d Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Tue, 11 Aug 2015 11:52:08 +0200 Subject: [PATCH 3/5] Added opening sound --- src/pocketmine/block/Trapdoor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index c3b8f8a70..434b3264b 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -146,11 +146,11 @@ class Trapdoor extends Transparent{ public function onActivate(Item $item, Player $player = null){ $this->meta ^= 0x04; $this->getLevel()->setBlock($this, $this, true); - + $this->level->addSound(new DoorSound($this)); return true; } public function getToolType(){ return Tool::TYPE_AXE; } -} \ No newline at end of file +} From 311d8d94dd1d5530ab20aa54fe38d29a53ce34a4 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Tue, 11 Aug 2015 12:48:41 +0200 Subject: [PATCH 4/5] Added sound for opening/closing (FenceGates) Added DoorSound on opening/closing FenceGates depending on #3367 @0929hitoshi 's Idea --- src/pocketmine/block/FenceGate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index 582ddc92c..7c0e0f8ea 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -107,7 +107,7 @@ class FenceGate extends Transparent{ ]; $this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04); $this->getLevel()->setBlock($this, $this, true); - + $this->level->addSound(new DoorSound($this)); return true; } -} \ No newline at end of file +} From 25b9946d9ef0eb0c55ff7842c3aaa5735e0ab8c7 Mon Sep 17 00:00:00 2001 From: Marcus Zhou Date: Tue, 11 Aug 2015 23:06:40 +0800 Subject: [PATCH 5/5] Fix wrong id passed to constructer in CookedFish.php --- src/pocketmine/item/CookedFish.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/item/CookedFish.php b/src/pocketmine/item/CookedFish.php index 4b4089fbe..9c7441ea4 100644 --- a/src/pocketmine/item/CookedFish.php +++ b/src/pocketmine/item/CookedFish.php @@ -24,10 +24,10 @@ namespace pocketmine\item; class CookedFish extends Item{ public function __construct($meta = 0, $count = 1){ - parent::__construct(self::RAW_FISH, $meta, $count, "Cooked Fish"); + parent::__construct(self::COOKED_FISH, $meta, $count, "Cooked Fish"); if($this->meta === 1){ $this->name = "Cooked Salmon"; } } -} \ No newline at end of file +}