Added player.block.(break/place).invalid handling events

This commit is contained in:
Shoghi Cervantes Pueyo 2013-03-30 20:26:15 +01:00
parent 121fd51dc6
commit 949ab34b42

View File

@ -170,7 +170,7 @@ class BlockAPI{
return $this->cancelAction($target, $player);
}
if(!$target->isBreakable($item, $player) or $player->gamemode === ADVENTURE or ($player->lastBreak + $target->getBreakTime($item, $player)) >= microtime(true)){
if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", array("player" => $player, "target" => $target, "item" => $item)) !== true) or $player->gamemode === ADVENTURE or ($player->lastBreak + $target->getBreakTime($item, $player)) >= microtime(true)){
return $this->cancelAction($target, $player);
}
@ -225,7 +225,7 @@ class BlockAPI{
$block = $this->getBlockFace($target, $face);
$item = $player->equipment;
if($target->getID() === AIR){ //If no block exists
if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists
$this->cancelAction($target, $player);
return $this->cancelAction($block, $player);
}