mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Merge branch 'stable' into next-minor
This commit is contained in:
@@ -109,6 +109,7 @@ use function base64_encode;
|
||||
use function count;
|
||||
use function fmod;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function is_infinite;
|
||||
use function is_nan;
|
||||
use function json_decode;
|
||||
@@ -418,6 +419,8 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
//TODO: end hack for client spam bug
|
||||
|
||||
self::validateFacing($data->getFace());
|
||||
|
||||
$blockPos = $data->getBlockPosition();
|
||||
$vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
|
||||
if(!$this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos)){
|
||||
@@ -449,6 +452,15 @@ class InGamePacketHandler extends PacketHandler{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws PacketHandlingException
|
||||
*/
|
||||
private static function validateFacing(int $facing) : void{
|
||||
if(!in_array($facing, Facing::ALL, true)){
|
||||
throw new PacketHandlingException("Invalid facing value $facing");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function used to execute rollbacks when an action fails on a block.
|
||||
*/
|
||||
@@ -565,6 +577,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
|
||||
switch($action){
|
||||
case PlayerAction::START_BREAK:
|
||||
self::validateFacing($face);
|
||||
if(!$this->player->attackBlock($pos, $face)){
|
||||
$this->onFailedBlockAction($pos, $face);
|
||||
}
|
||||
@@ -582,6 +595,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
$this->player->stopSleep();
|
||||
break;
|
||||
case PlayerAction::CRACK_BREAK:
|
||||
self::validateFacing($face);
|
||||
$this->player->continueBreakBlock($pos, $face);
|
||||
break;
|
||||
case PlayerAction::INTERACT_BLOCK: //TODO: ignored (for now)
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\thread;
|
||||
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use const PTHREADS_INHERIT_NONE;
|
||||
|
||||
/**
|
||||
|
@@ -503,9 +503,6 @@ final class Utils{
|
||||
*/
|
||||
public static function parseDocComment(string $docComment) : array{
|
||||
$rawDocComment = substr($docComment, 3, -2); //remove the opening and closing markers
|
||||
if($rawDocComment === false){ //usually empty doc comment, but this is safer and statically analysable
|
||||
return [];
|
||||
}
|
||||
preg_match_all('/(*ANYCRLF)^[\t ]*(?:\* )?@([a-zA-Z\-]+)(?:[\t ]+(.+?))?[\t ]*$/m', $rawDocComment, $matches);
|
||||
|
||||
return array_combine($matches[1], $matches[2]);
|
||||
|
Reference in New Issue
Block a user