From 5926d80525318d73f633cedfb6d5fedb91f75f3e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 4 Jul 2018 20:04:40 +0100 Subject: [PATCH 1/4] DoubleChestInventory: fixed wrong logic for setting items into the right-hand side --- src/pocketmine/inventory/DoubleChestInventory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index e302fcf56..57600a2a5 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -60,15 +60,15 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ } public function getItem(int $index) : Item{ - return $index < $this->left->getSize() ? $this->left->getItem($index) : $this->right->getItem($index - $this->right->getSize()); + return $index < $this->left->getSize() ? $this->left->getItem($index) : $this->right->getItem($index - $this->left->getSize()); } public function setItem(int $index, Item $item, bool $send = true) : bool{ - return $index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->right->getSize(), $item, $send); + return $index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send); } public function clear(int $index, bool $send = true) : bool{ - return $index < $this->left->getSize() ? $this->left->clear($index, $send) : $this->right->clear($index - $this->right->getSize(), $send); + return $index < $this->left->getSize() ? $this->left->clear($index, $send) : $this->right->clear($index - $this->left->getSize(), $send); } public function getContents(bool $includeEmpty = false) : array{ From 697723b551fcc565b4c04c4764c317e968d3e22e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 4 Jul 2018 20:06:42 +0100 Subject: [PATCH 2/4] DoubleChestInventory: remove redundant clear() override this calls setItem() which deals with the necessary logic anyway. --- src/pocketmine/inventory/DoubleChestInventory.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index 57600a2a5..06578e19f 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -67,10 +67,6 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ return $index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send); } - public function clear(int $index, bool $send = true) : bool{ - return $index < $this->left->getSize() ? $this->left->clear($index, $send) : $this->right->clear($index - $this->left->getSize(), $send); - } - public function getContents(bool $includeEmpty = false) : array{ $result = $this->left->getContents($includeEmpty); $leftSize = $this->left->getSize(); From 0df3585c814ab5fdc91e6863b1a39d5002cfe6ac Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 5 Jul 2018 09:12:21 +0100 Subject: [PATCH 3/4] TellCommand: remove useless strtolower() and temp variable --- src/pocketmine/command/defaults/TellCommand.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pocketmine/command/defaults/TellCommand.php b/src/pocketmine/command/defaults/TellCommand.php index 714e7b11a..e73983bc2 100644 --- a/src/pocketmine/command/defaults/TellCommand.php +++ b/src/pocketmine/command/defaults/TellCommand.php @@ -50,9 +50,7 @@ class TellCommand extends VanillaCommand{ throw new InvalidCommandSyntaxException(); } - $name = strtolower(array_shift($args)); - - $player = $sender->getServer()->getPlayer($name); + $player = $sender->getServer()->getPlayer(array_shift($args)); if($player === $sender){ $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.message.sameTarget")); From 58f0ad3e3e935042e9b3152876468317f06ad4b4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 5 Jul 2018 10:38:31 +0100 Subject: [PATCH 4/4] Command: remove unnecessary getPermission() calls --- src/pocketmine/command/Command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 759eed18f..09231ffe4 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -127,7 +127,7 @@ abstract class Command{ if($this->permissionMessage === null){ $target->sendMessage($target->getServer()->getLanguage()->translateString(TextFormat::RED . "%commands.generic.permission")); }elseif($this->permissionMessage !== ""){ - $target->sendMessage(str_replace("", $this->getPermission(), $this->permissionMessage)); + $target->sendMessage(str_replace("", $this->permission, $this->permissionMessage)); } return false; @@ -139,11 +139,11 @@ abstract class Command{ * @return bool */ public function testPermissionSilent(CommandSender $target) : bool{ - if(($perm = $this->getPermission()) === null or $perm === ""){ + if($this->permission === null or $this->permission === ""){ return true; } - foreach(explode(";", $perm) as $permission){ + foreach(explode(";", $this->permission) as $permission){ if($target->hasPermission($permission)){ return true; }