Skip to content

Commit

Permalink
Using isset in this case.
Browse files Browse the repository at this point in the history
  • Loading branch information
matcracker committed Apr 18, 2020
1 parent fb972ed commit 56714cb
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/matcracker/BedcoreProtect/commands/BCPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -126,30 +125,29 @@ 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);
} else {
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()}"));
Expand All @@ -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')));
Expand Down Expand Up @@ -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')));

Expand All @@ -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()])));
Expand All @@ -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()])));
Expand Down

0 comments on commit 56714cb

Please sign in to comment.