StructureGrowEvent: added API to get the player who caused the growth (#4445)

This commit is contained in:
Matt
2021-10-09 23:51:46 +02:00
committed by GitHub
parent ccc881ee58
commit 09715906c8
4 changed files with 25 additions and 14 deletions

View File

@ -7,6 +7,7 @@ namespace pocketmine\event\block;
use pocketmine\block\Block;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
/**
@ -17,13 +18,23 @@ class StructureGrowEvent extends BlockEvent implements Cancellable{
use CancellableTrait;
private BlockTransaction $transaction;
private ?Player $player;
public function __construct(Block $block, BlockTransaction $transaction){
public function __construct(Block $block, BlockTransaction $transaction, ?Player $player){
parent::__construct($block);
$this->transaction = $transaction;
$this->player = $player;
}
public function getTransaction() : BlockTransaction{
return $this->transaction;
}
/**
* It returns the player which grows the structure.
* It returns null when the structure grows by itself.
*/
public function getPlayer() : ?Player{
return $this->player;
}
}