From 23829952c379167f266512cae57787c85c327cf5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 8 Jul 2018 13:04:51 +0100 Subject: [PATCH 1/3] PermissibleBase: removed nonsensical code it's not possible for this to be null, unless a child class doesn't call the constructor, and anything could break in that case anyway. --- src/pocketmine/permission/PermissibleBase.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/pocketmine/permission/PermissibleBase.php b/src/pocketmine/permission/PermissibleBase.php index 1f627785bf..bec0fab46d 100644 --- a/src/pocketmine/permission/PermissibleBase.php +++ b/src/pocketmine/permission/PermissibleBase.php @@ -30,7 +30,7 @@ use pocketmine\timings\Timings; class PermissibleBase implements Permissible{ /** @var ServerOperator */ - private $opable = null; + private $opable; /** @var Permissible */ private $parent = null; @@ -59,24 +59,14 @@ class PermissibleBase implements Permissible{ * @return bool */ public function isOp() : bool{ - if($this->opable === null){ - return false; - }else{ - return $this->opable->isOp(); - } + return $this->opable->isOp(); } /** * @param bool $value - * - * @throws \Exception */ public function setOp(bool $value){ - if($this->opable === null){ - throw new \LogicException("Cannot change op value as no ServerOperator is set"); - }else{ - $this->opable->setOp($value); - } + $this->opable->setOp($value); } /** From 066c9d4fd458d8d8b61934ea56cc58ea7b113c30 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 8 Jul 2018 16:16:39 +0100 Subject: [PATCH 2/3] PluginManager: simplify isPluginEnabled() --- src/pocketmine/plugin/PluginManager.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 861ea2e1a7..0ce695313b 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -596,11 +596,7 @@ class PluginManager{ * @return bool */ public function isPluginEnabled(Plugin $plugin) : bool{ - if($plugin instanceof Plugin and isset($this->plugins[$plugin->getDescription()->getName()])){ - return $plugin->isEnabled(); - }else{ - return false; - } + return isset($this->plugins[$plugin->getDescription()->getName()]) and $plugin->isEnabled(); } /** From 2d454ae56f01f7c2296e0f9d5d1577fa3a215a6d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 8 Jul 2018 16:19:46 +0100 Subject: [PATCH 3/3] PluginManager: fixed bug in YML commands permission type checking --- 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 0ce695313b..a709e253d0 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -665,7 +665,7 @@ class PluginManager{ }elseif(is_string($data["permission"])){ $newCmd->setPermission($data["permission"]); }else{ - throw new \InvalidArgumentException("Permission must be a string or boolean, " . gettype($data["permission"] . " given")); + throw new \InvalidArgumentException("Permission must be a string or boolean, " . gettype($data["permission"]) . " given"); } }