Fixed request rejecting

This commit is contained in:
Dylan K. Taylor 2023-03-20 01:35:03 +00:00
parent eece6c4433
commit 4e55433ed8
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
5 changed files with 17 additions and 14 deletions

View File

@ -37,7 +37,7 @@
"pocketmine/bedrock-block-upgrade-schema": "~1.1.1+bedrock-1.19.70",
"pocketmine/bedrock-data": "~2.1.1+bedrock-1.19.70",
"pocketmine/bedrock-item-upgrade-schema": "~1.1.0+bedrock-1.19.70",
"pocketmine/bedrock-protocol": "~20.0.0+bedrock-1.19.70",
"pocketmine/bedrock-protocol": "~20.1.0+bedrock-1.19.70",
"pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "^0.2.0",

16
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1d0c1d2fe668d85ae87110a1e3cfac05",
"content-hash": "01afa65b40f95ad9378c8cd999e6098d",
"packages": [
{
"name": "adhocore/json-comment",
@ -328,16 +328,16 @@
},
{
"name": "pocketmine/bedrock-protocol",
"version": "20.0.0+bedrock-1.19.70",
"version": "20.1.0+bedrock-1.19.70",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "4892a5020187da805d7b46ab522d8185b0283726"
"reference": "91d67c8b1bced3c82d0841b1041c0c1f4e93eb68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/4892a5020187da805d7b46ab522d8185b0283726",
"reference": "4892a5020187da805d7b46ab522d8185b0283726",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/91d67c8b1bced3c82d0841b1041c0c1f4e93eb68",
"reference": "91d67c8b1bced3c82d0841b1041c0c1f4e93eb68",
"shasum": ""
},
"require": {
@ -351,7 +351,7 @@
"ramsey/uuid": "^4.1"
},
"require-dev": {
"phpstan/phpstan": "1.10.1",
"phpstan/phpstan": "1.10.7",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5"
@ -369,9 +369,9 @@
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
"support": {
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
"source": "https://github.com/pmmp/BedrockProtocol/tree/20.0.0+bedrock-1.19.70"
"source": "https://github.com/pmmp/BedrockProtocol/tree/20.1.0+bedrock-1.19.70"
},
"time": "2023-03-14T17:06:38+00:00"
"time": "2023-03-20T01:17:00+00:00"
},
{
"name": "pocketmine/binaryutils",

View File

@ -541,7 +541,10 @@ class InGamePacketHandler extends PacketHandler{
$this->session->getLogger()->debug(implode("\n", Utils::printableExceptionInfo($e)));
}
return $executor->buildItemStackResponse($result);
if(!$result){
return new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
}
return $executor->buildItemStackResponse();
}
public function handleItemStackRequest(ItemStackRequestPacket $packet) : bool{

View File

@ -349,12 +349,12 @@ final class ItemStackRequestExecutor{
return $transaction;
}
public function buildItemStackResponse(bool $success) : ItemStackResponse{
public function buildItemStackResponse() : ItemStackResponse{
$builder = new ItemStackResponseBuilder($this->request->getRequestId(), $this->inventoryManager);
foreach($this->requestSlotInfos as $requestInfo){
$builder->addSlot($requestInfo->getContainerId(), $requestInfo->getSlotId());
}
return $builder->build($success);
return $builder->build();
}
}

View File

@ -65,7 +65,7 @@ final class ItemStackResponseBuilder{
return [$inventory, $slot];
}
public function build(bool $success) : ItemStackResponse{
public function build() : ItemStackResponse{
$responseInfosByContainer = [];
foreach($this->changedSlots as $containerInterfaceId => $slotIds){
if($containerInterfaceId === ContainerUIIds::CREATED_OUTPUT){
@ -107,6 +107,6 @@ final class ItemStackResponseBuilder{
$responseContainerInfos[] = new ItemStackResponseContainerInfo($containerInterfaceId, $responseInfos);
}
return new ItemStackResponse($success ? ItemStackResponse::RESULT_OK : ItemStackResponse::RESULT_ERROR, $this->requestId, $responseContainerInfos);
return new ItemStackResponse(ItemStackResponse::RESULT_OK, $this->requestId, $responseContainerInfos);
}
}