Skip to content

Commit

Permalink
Allowed radius in lookup command
Browse files Browse the repository at this point in the history
  • Loading branch information
matcracker committed May 7, 2021
1 parent 853b0ee commit c7baa57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/matcracker/BedcoreProtect/commands/CommandParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public function getErrorMessage(): ?string
return $this->errorMessage;
}

public function buildLookupQuery(string &$query, array &$args): void
public function buildLookupQuery(string &$query, array &$args, ?AxisAlignedBB $bb = null): void
{
if (!$this->parsed) {
throw new BadMethodCallException('Before invoking this method, you need to invoke CommandParser::parse()');
Expand Down Expand Up @@ -502,7 +502,7 @@ public function buildLookupQuery(string &$query, array &$args): void
$variables = [];
$parameters = [];

$this->buildConditionalQuery($query, $variables, $parameters, null);
$this->buildConditionalQuery($query, $variables, $parameters, $bb);

$query .= ' ORDER BY time DESC;';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use matcracker\BedcoreProtect\commands\CommandParser;
use matcracker\BedcoreProtect\Inspector;
use matcracker\BedcoreProtect\math\Area;
use matcracker\BedcoreProtect\math\MathUtils;
use pocketmine\block\Block;
use pocketmine\command\CommandSender;
use pocketmine\level\Position;
Expand Down Expand Up @@ -75,7 +76,13 @@ public function requestLookup(CommandSender $sender, CommandParser $parser): voi
$query = "";
$args = [];

$parser->buildLookupQuery($query, $args);
if ($sender instanceof Player && $parser->getRadius() !== null) {
$bb = MathUtils::getRangedVector($sender->asVector3(), $parser->getRadius());
} else {
$bb = null;
}

$parser->buildLookupQuery($query, $args, $bb);

$this->connector->executeSelectRaw(
$query,
Expand Down

0 comments on commit c7baa57

Please sign in to comment.