From 56714cbc4c9c8049473176a2b4bae3a5a357d437 Mon Sep 17 00:00:00 2001 From: matcracker Date: Sat, 18 Apr 2020 17:24:43 +0200 Subject: [PATCH] Using isset in this case. --- .../BedcoreProtect/commands/BCPCommand.php | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/matcracker/BedcoreProtect/commands/BCPCommand.php b/src/matcracker/BedcoreProtect/commands/BCPCommand.php index 0f10ff39..fbec6907 100644 --- a/src/matcracker/BedcoreProtect/commands/BCPCommand.php +++ b/src/matcracker/BedcoreProtect/commands/BCPCommand.php @@ -37,7 +37,6 @@ use pocketmine\plugin\Plugin; use pocketmine\utils\TextFormat; use SOFe\AwaitGenerator\Await; -use function array_key_exists; use function count; use function ctype_digit; use function explode; @@ -126,7 +125,7 @@ static function (): void { ); return true; case 'lookup': - if (array_key_exists(1, $args)) { + if (isset($args[1])) { $parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time'], true); if ($parser->parse()) { $this->queryManager->getPluginQueries()->requestLookup($sender, $parser); @@ -134,22 +133,21 @@ static function (): void { if (count($logs = Inspector::getCachedLogs($sender)) > 0) { $page = 0; $lines = 4; - if (array_key_exists(1, $args)) { - $split = explode(":", $args[1]); - if ($ctype = ctype_digit($split[0])) { - $page = (int)$split[0]; - } + $split = explode(":", $args[1]); + if ($ctype = ctype_digit($split[0])) { + $page = (int)$split[0]; + } - if (array_key_exists(1, $split) && $ctype = ctype_digit($split[1])) { - $lines = (int)$split[1]; - } + if (isset($split[1]) && $ctype = ctype_digit($split[1])) { + $lines = (int)$split[1]; + } - if (!$ctype) { - $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . '&c' . $lang->translateString('command.error.no-numeric-value'))); + if (!$ctype) { + $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . '&c' . $lang->translateString('command.error.no-numeric-value'))); - return true; - } + return true; } + Inspector::parseLogs($sender, $logs, ($page - 1), $lines); } else { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . "&c{$parser->getErrorMessage()}")); @@ -161,7 +159,7 @@ static function (): void { return true; case 'purge': - if (array_key_exists(1, $args)) { + if (isset($args[1])) { $parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time'], true); if ($parser->parse()) { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.purge.started'))); @@ -206,7 +204,7 @@ static function (): void { case 'near': $near = 5; - if (array_key_exists(1, $args)) { + if (isset($args[1])) { if (!ctype_digit($args[1])) { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . '&c' . $lang->translateString('command.error.no-numeric-value'))); @@ -225,7 +223,7 @@ static function (): void { return true; case 'rollback': - if (array_key_exists(1, $args)) { + if (isset($args[1])) { $parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time', 'radius'], true); if ($parser->parse()) { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.rollback.started', [$sender->getLevel()->getName()]))); @@ -241,7 +239,7 @@ static function (): void { return true; case 'restore': - if (array_key_exists(1, $args)) { + if (isset($args[1])) { $parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time', 'radius'], true); if ($parser->parse()) { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.restore.started', [$sender->getLevel()->getName()])));