From d669a6f0c7bb8eb3d4c83ef5a7f3c99a608553e1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 27 Jul 2022 03:51:06 +0100 Subject: [PATCH 01/21] ReversePriorityQueue: add ReturnTypeWillChange attribute it's doubtful any plugin dev is extending this, but nonetheless, we can't change it in a patch. --- src/utils/ReversePriorityQueue.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/ReversePriorityQueue.php b/src/utils/ReversePriorityQueue.php index 76e648231..53fd0f08a 100644 --- a/src/utils/ReversePriorityQueue.php +++ b/src/utils/ReversePriorityQueue.php @@ -38,6 +38,7 @@ class ReversePriorityQueue extends \SplPriorityQueue{ * * @return int */ + #[\ReturnTypeWillChange] public function compare($priority1, $priority2){ //TODO: this will crash if non-numeric priorities are used return (int) -($priority1 - $priority2); From 554182b2cb96eb5c1fe25b545392f8fdd18a2551 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 6 Aug 2022 15:27:11 +0100 Subject: [PATCH 02/21] Update composer dependencies --- composer.json | 2 +- composer.lock | 63 ++++++++++++++++++++++++--------------------------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index 3e925b4c7..4e011f884 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.8.0", + "phpstan/phpstan": "1.8.2", "phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-strict-rules": "^1.2.0", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index ad83e7609..5b65af9f7 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "e03c7f446cee1fdb97ee79817c78470a", + "content-hash": "f9d81230e16fff707deb5cbe7ff37376", "packages": [ { "name": "adhocore/json-comment", @@ -63,26 +63,26 @@ }, { "name": "brick/math", - "version": "0.9.3", + "version": "0.10.1", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae" + "reference": "de846578401f4e58f911b3afeb62ced56365ed87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/ca57d18f028f84f777b2168cd1911b0dee2343ae", - "reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae", + "url": "https://api.github.com/repos/brick/math/zipball/de846578401f4e58f911b3afeb62ced56365ed87", + "reference": "de846578401f4e58f911b3afeb62ced56365ed87", "shasum": "" }, "require": { "ext-json": "*", - "php": "^7.1 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0", - "vimeo/psalm": "4.9.2" + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "4.25.0" }, "type": "library", "autoload": { @@ -107,19 +107,15 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.9.3" + "source": "https://github.com/brick/math/tree/0.10.1" }, "funding": [ { "url": "https://github.com/BenMorel", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/brick/math", - "type": "tidelift" } ], - "time": "2021-08-15T20:50:18+00:00" + "time": "2022-08-01T22:54:31+00:00" }, { "name": "fgrosse/phpasn1", @@ -275,16 +271,16 @@ }, { "name": "pocketmine/bedrock-protocol", - "version": "11.0.0+bedrock-1.19.10", + "version": "11.0.4+bedrock-1.19.10", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockProtocol.git", - "reference": "705f928bd010ba093d8781d20006e4cd5f79f335" + "reference": "1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/705f928bd010ba093d8781d20006e4cd5f79f335", - "reference": "705f928bd010ba093d8781d20006e4cd5f79f335", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab", + "reference": "1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab", "shasum": "" }, "require": { @@ -316,9 +312,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/11.0.0+bedrock-1.19.10" + "source": "https://github.com/pmmp/BedrockProtocol/tree/11.0.4+bedrock-1.19.10" }, - "time": "2022-07-12T23:47:47+00:00" + "time": "2022-07-24T19:22:18+00:00" }, { "name": "pocketmine/binaryutils", @@ -930,20 +926,20 @@ }, { "name": "ramsey/uuid", - "version": "4.3.1", + "version": "4.4.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "8505afd4fea63b81a85d3b7b53ac3cb8dc347c28" + "reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/8505afd4fea63b81a85d3b7b53ac3cb8dc347c28", - "reference": "8505afd4fea63b81a85d3b7b53ac3cb8dc347c28", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/373f7bacfcf3de038778ff27dcce5672ddbf4c8a", + "reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a", "shasum": "" }, "require": { - "brick/math": "^0.8 || ^0.9", + "brick/math": "^0.8 || ^0.9 || ^0.10", "ext-ctype": "*", "ext-json": "*", "php": "^8.0", @@ -959,7 +955,6 @@ "doctrine/annotations": "^1.8", "ergebnis/composer-normalize": "^2.15", "mockery/mockery": "^1.3", - "moontoast/math": "^1.1", "paragonie/random-lib": "^2", "php-mock/php-mock": "^2.2", "php-mock/php-mock-mockery": "^1.3", @@ -1008,7 +1003,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.3.1" + "source": "https://github.com/ramsey/uuid/tree/4.4.0" }, "funding": [ { @@ -1020,7 +1015,7 @@ "type": "tidelift" } ], - "time": "2022-03-27T21:42:02+00:00" + "time": "2022-08-05T17:58:37+00:00" }, { "name": "symfony/polyfill-php81", @@ -1737,16 +1732,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.0", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b7648d4ee9321665acaf112e49da9fd93df8fbd5" + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b7648d4ee9321665acaf112e49da9fd93df8fbd5", - "reference": "b7648d4ee9321665acaf112e49da9fd93df8fbd5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c", + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c", "shasum": "" }, "require": { @@ -1772,7 +1767,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.0" + "source": "https://github.com/phpstan/phpstan/tree/1.8.2" }, "funding": [ { @@ -1792,7 +1787,7 @@ "type": "tidelift" } ], - "time": "2022-06-29T08:53:31+00:00" + "time": "2022-07-20T09:57:31+00:00" }, { "name": "phpstan/phpstan-phpunit", From 9abbb85a93a146ffb58347ae4b48c61a5ccf8383 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 6 Aug 2022 15:35:47 +0100 Subject: [PATCH 03/21] Release 4.6.2 --- changelogs/4.6.md | 11 +++++++++++ src/VersionInfo.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/changelogs/4.6.md b/changelogs/4.6.md index e32098da6..82fc1af8f 100644 --- a/changelogs/4.6.md +++ b/changelogs/4.6.md @@ -29,3 +29,14 @@ Released 22nd July 2022. - Fixed incorrect fire ticks when being set on fire by lava (8 seconds in Bedrock instead of 15). - `Entity->attack()` now cancels damage from `FIRE` and `FIRE_TICK` damage causes if the entity is fireproof. - Fixed inventory windows getting force-closed when the client attempts to use an enchanting table or anvil. + +# 4.6.2 +Released 6th August 2022. + +## Core +- Improved server-side performance of `PlayerAuthInputPacket` handler. +- Improved client-side performance of `FloatingTextParticle` by using an invisible falling block entity. This offered a roughly 5x performance improvement over using tiny invisible players in local testing. + +## Fixes +- Fixed assert failures and debug spam on debug Minecraft clients related to abilities in `AddPlayerPacket`. +- Fixed crash in `ReversePriorityQueue` on PHP 8.1 by adding `#[ReturnTypeWillChange]` attribute. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 1be7896ff..a83207968 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -32,7 +32,7 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; public const BASE_VERSION = "4.6.2"; - public const IS_DEVELOPMENT_BUILD = true; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "stable"; private function __construct(){ From 5c6927e16c6d80663d38aa7b28a329e4909488a2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 6 Aug 2022 15:35:47 +0100 Subject: [PATCH 04/21] 4.6.3 is next --- src/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VersionInfo.php b/src/VersionInfo.php index a83207968..3042026f3 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.6.2"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "4.6.3"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; private function __construct(){ From 5c72807b16eded70a90f0d8f570f2adab174f56a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Aug 2022 15:39:36 +0100 Subject: [PATCH 05/21] Bump shivammathur/setup-php from 2.21.0 to 2.21.1 (#5199) Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.21.0 to 2.21.1. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.21.0...2.21.1) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/draft-release.yml | 2 +- .github/workflows/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 9cb10390e..9ee5cb920 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -18,7 +18,7 @@ jobs: submodules: true - name: Setup PHP - uses: shivammathur/setup-php@2.21.0 + uses: shivammathur/setup-php@2.21.1 with: php-version: 8.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 08b4e253c..b46d7f8eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -195,7 +195,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP and tools - uses: shivammathur/setup-php@2.21.0 + uses: shivammathur/setup-php@2.21.1 with: php-version: 8.0 tools: php-cs-fixer:3.2 From d77a95e4aff2c94312ce1dd3d8c4cfd2c7cdecc4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 6 Aug 2022 15:48:51 +0100 Subject: [PATCH 06/21] actions/draft-release: bake the full changelog blob URL into the release notes, to ensure it works properly in emails and embeds --- .github/workflows/draft-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 9ee5cb920..edd250384 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -80,4 +80,4 @@ jobs: body: | **For Minecraft: Bedrock Edition ${{ steps.get-pm-version.outputs.MCPE_VERSION }}** - Please see the [changelogs](/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details. + Please see the [changelogs](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get-pm-version.outputs.PM_VERSION }}/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details. From df7a1fcba63bb19df8a8a08dd5b4295dabfddca8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Aug 2022 19:06:05 +0100 Subject: [PATCH 07/21] Changes for 1.19.20 --- composer.json | 4 +-- composer.lock | 26 +++++++++---------- src/entity/Entity.php | 2 +- src/network/mcpe/ChunkRequestTask.php | 3 ++- src/network/mcpe/NetworkSession.php | 4 +-- .../mcpe/handler/InGamePacketHandler.php | 9 ++++++- .../mcpe/handler/PreSpawnPacketHandler.php | 3 ++- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 4e011f884..5334687cf 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,8 @@ "adhocore/json-comment": "^1.1", "fgrosse/phpasn1": "^2.3", "netresearch/jsonmapper": "^4.0", - "pocketmine/bedrock-data": "~1.9.0+bedrock-1.19.10", - "pocketmine/bedrock-protocol": "~11.0.0+bedrock-1.19.10", + "pocketmine/bedrock-data": "~1.10.0+bedrock-1.19.20", + "pocketmine/bedrock-protocol": "~12.0.0+bedrock-1.19.20", "pocketmine/binaryutils": "^0.2.1", "pocketmine/callback-validator": "^1.0.2", "pocketmine/classloader": "^0.2.0", diff --git a/composer.lock b/composer.lock index 5b65af9f7..34cce5d63 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "f9d81230e16fff707deb5cbe7ff37376", + "content-hash": "80afa24adf37096a23643e051d6128ce", "packages": [ { "name": "adhocore/json-comment", @@ -245,16 +245,16 @@ }, { "name": "pocketmine/bedrock-data", - "version": "1.9.0+bedrock-1.19.10", + "version": "1.10.0+bedrock-1.19.20", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockData.git", - "reference": "ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1" + "reference": "43610f6749f22d15ede6b60ed5402bdeff47453e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1", - "reference": "ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1", + "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/43610f6749f22d15ede6b60ed5402bdeff47453e", + "reference": "43610f6749f22d15ede6b60ed5402bdeff47453e", "shasum": "" }, "type": "library", @@ -265,22 +265,22 @@ "description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/BedrockData/issues", - "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.19.10" + "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.19.20" }, - "time": "2022-07-12T19:33:21+00:00" + "time": "2022-08-09T17:44:22+00:00" }, { "name": "pocketmine/bedrock-protocol", - "version": "11.0.4+bedrock-1.19.10", + "version": "12.0.0+bedrock-1.19.20", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockProtocol.git", - "reference": "1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab" + "reference": "c2778039544fa0c7c5bd3af7963149e7552f4215" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab", - "reference": "1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/c2778039544fa0c7c5bd3af7963149e7552f4215", + "reference": "c2778039544fa0c7c5bd3af7963149e7552f4215", "shasum": "" }, "require": { @@ -312,9 +312,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/11.0.4+bedrock-1.19.10" + "source": "https://github.com/pmmp/BedrockProtocol/tree/bedrock-1.19.20" }, - "time": "2022-07-24T19:22:18+00:00" + "time": "2022-08-09T17:57:29+00:00" }, { "name": "pocketmine/binaryutils", diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 40382c564..54873f9f1 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1466,7 +1466,7 @@ abstract class Entity{ $this->location->yaw, //TODO: head yaw $this->location->yaw, //TODO: body yaw (wtf mojang?) array_map(function(Attribute $attr) : NetworkAttribute{ - return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue()); + return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue(), []); }, $this->attributeMap->getAll()), $this->getAllNetworkData(), [] //TODO: entity links diff --git a/src/network/mcpe/ChunkRequestTask.php b/src/network/mcpe/ChunkRequestTask.php index 1be39e978..f66614099 100644 --- a/src/network/mcpe/ChunkRequestTask.php +++ b/src/network/mcpe/ChunkRequestTask.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelChunkPacket; use pocketmine\network\mcpe\protocol\serializer\PacketBatch; use pocketmine\network\mcpe\protocol\serializer\PacketSerializerContext; +use pocketmine\network\mcpe\protocol\types\ChunkPosition; use pocketmine\network\mcpe\serializer\ChunkSerializer; use pocketmine\scheduler\AsyncTask; use pocketmine\world\format\Chunk; @@ -71,7 +72,7 @@ class ChunkRequestTask extends AsyncTask{ $subCount = ChunkSerializer::getSubChunkCount($chunk) + ChunkSerializer::LOWER_PADDING_SIZE; $encoderContext = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()); $payload = ChunkSerializer::serializeFullChunk($chunk, RuntimeBlockMapping::getInstance(), $encoderContext, $this->tiles); - $this->setResult($this->compressor->compress(PacketBatch::fromPackets($encoderContext, LevelChunkPacket::create($this->chunkX, $this->chunkZ, $subCount, false, null, $payload))->getBuffer())); + $this->setResult($this->compressor->compress(PacketBatch::fromPackets($encoderContext, LevelChunkPacket::create(new ChunkPosition($this->chunkX, $this->chunkZ), $subCount, false, null, $payload))->getBuffer())); } public function onError() : void{ diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 9fde7ed23..da0a1c26a 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -756,7 +756,7 @@ class NetworkSession{ } public function syncViewAreaCenterPoint(Vector3 $newPos, int $viewDistance) : void{ - $this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(BlockPosition::fromVector3($newPos), $viewDistance * 16)); //blocks, not chunks >.> + $this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(BlockPosition::fromVector3($newPos), $viewDistance * 16, [])); //blocks, not chunks >.> } public function syncPlayerSpawnPoint(Position $newSpawn) : void{ @@ -834,7 +834,7 @@ class NetworkSession{ public function syncAttributes(Living $entity, array $attributes) : void{ if(count($attributes) > 0){ $this->sendDataPacket(UpdateAttributesPacket::create($entity->getId(), array_map(function(Attribute $attr) : NetworkAttribute{ - return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue()); + return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue(), []); }, $attributes), 0)); } } diff --git a/src/network/mcpe/handler/InGamePacketHandler.php b/src/network/mcpe/handler/InGamePacketHandler.php index 6cf39609e..af38ac0f6 100644 --- a/src/network/mcpe/handler/InGamePacketHandler.php +++ b/src/network/mcpe/handler/InGamePacketHandler.php @@ -890,7 +890,14 @@ class InGamePacketHandler extends PacketHandler{ } public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{ - return $this->player->onFormSubmit($packet->formId, self::stupid_json_decode($packet->formData, true)); + if($packet->cancelReason !== null){ + //TODO: make APIs for this to allow plugins to use this information + return $this->player->onFormSubmit($packet->formId, null); + }elseif($packet->formData !== null){ + return $this->player->onFormSubmit($packet->formId, self::stupid_json_decode($packet->formData, true)); + }else{ + throw new PacketHandlingException("Expected either formData or cancelReason to be set in ModalFormResponsePacket"); + } } /** diff --git a/src/network/mcpe/handler/PreSpawnPacketHandler.php b/src/network/mcpe/handler/PreSpawnPacketHandler.php index 5237cdb4d..f9ff35808 100644 --- a/src/network/mcpe/handler/PreSpawnPacketHandler.php +++ b/src/network/mcpe/handler/PreSpawnPacketHandler.php @@ -98,9 +98,10 @@ class PreSpawnPacketHandler extends PacketHandler{ false, sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true)), Uuid::fromString(Uuid::NIL), + false, [], 0, - GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries() + GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(), )); $this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers()); From c2b599166c9942865996f967c17c9dcc0fe48def Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Aug 2022 19:21:36 +0100 Subject: [PATCH 08/21] Added new shiny webhook for Discord release notifications --- .github/workflows/discord-release-embed.php | 100 +++++++++++++++++++ .github/workflows/discord-release-notify.yml | 25 +++++ 2 files changed, 125 insertions(+) create mode 100644 .github/workflows/discord-release-embed.php create mode 100644 .github/workflows/discord-release-notify.yml diff --git a/.github/workflows/discord-release-embed.php b/.github/workflows/discord-release-embed.php new file mode 100644 index 000000000..8c6213b83 --- /dev/null +++ b/.github/workflows/discord-release-embed.php @@ -0,0 +1,100 @@ + + */ +function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl) : array{ + return [ + "embeds" => [ + [ + "title" => "New PocketMine-MP release: $version ($channel)", + "description" => << $detailsUrl, + "color" => $channel === "stable" ? 0x57ab5a : 0xc69026 + ] + ] + ]; +} + +if(count($argv) !== 5){ + fwrite(STDERR, "Required arguments: github repo, version, API token\n"); + exit(1); +} +[, $repo, $tagName, $token, $hookURL] = $argv; + +$result = Internet::getURL('https://api.github.com/repos/' . $repo . '/releases/tags/' . $tagName, extraHeaders: [ + 'Authorization: token ' . $token +]); +if($result === null){ + fwrite(STDERR, "failed to access GitHub API\n"); + return; +} +if($result->getCode() !== 200){ + fwrite(STDERR, "Error accessing GitHub API: " . $result->getCode() . "\n"); + fwrite(STDERR, $result->getBody() . "\n"); + exit(1); +} + +$releaseInfoJson = json_decode($result->getBody(), true, JSON_THROW_ON_ERROR); +if(!is_array($releaseInfoJson)){ + fwrite(STDERR, "Invalid release JSON returned from GitHub API\n"); + exit(1); +} +$buildInfoPath = 'https://github.com/' . $repo . '/releases/download/' . $tagName . '/build_info.json'; + +$buildInfoResult = Internet::getURL($buildInfoPath, extraHeaders: [ + 'Authorization: token ' . $token +]); +if($buildInfoResult === null){ + fwrite(STDERR, "missing build_info.json\n"); + exit(1); +} +if($buildInfoResult->getCode() !== 200){ + fwrite(STDERR, "error accessing build_info.json: " . $buildInfoResult->getCode() . "\n"); + fwrite(STDERR, $buildInfoResult->getBody() . "\n"); + exit(1); +} + +$buildInfoJson = json_decode($buildInfoResult->getBody(), true, JSON_THROW_ON_ERROR); +if(!is_array($buildInfoJson)){ + fwrite(STDERR, "invalid build_info.json\n"); + exit(1); +} +$detailsUrl = $buildInfoJson["details_url"]; +$sourceUrl = $buildInfoJson["source_url"]; +$pharDownloadUrl = $buildInfoJson["download_url"]; + + +$description = $releaseInfoJson["body"]; + +$discordPayload = generateDiscordEmbed($buildInfoJson["base_version"], $buildInfoJson["channel"], $description, $detailsUrl, $sourceUrl, $pharDownloadUrl); + +$response = Internet::postURL( + $hookURL, + json_encode($discordPayload, JSON_THROW_ON_ERROR), + extraHeaders: ['Content-Type: application/json'] +); +if($response?->getCode() !== 204){ + fwrite(STDERR, "failed to send Discord webhook\n"); + fwrite(STDERR, $response?->getBody() ?? "no response body\n"); + exit(1); +} diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml new file mode 100644 index 000000000..94570dc21 --- /dev/null +++ b/.github/workflows/discord-release-notify.yml @@ -0,0 +1,25 @@ +name: Notify Discord webhook of release + +on: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP and tools + uses: shivammathur/setup-php@2.21.1 + with: + php-version: 8.0 + + - name: Get actual tag name + id: tag-name + run: echo ::set-output name=TAG_NAME::$(echo "${{ github.ref }}" | sed 's{^refs/tags/{{') + + - name: Run webhook post script + run: php .github/workflows/discord-release-embed.php ${{ github.repo }} ${{ steps.tag-name.outputs.TAG_NAME }} ${{ github.token }} ${{ secrets.DISCORD_RELEASE_WEBHOOK }} From a21419d120b092d02fd845de309ea484954e348d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Aug 2022 19:24:01 +0100 Subject: [PATCH 09/21] Release 4.7.0 --- changelogs/4.7.md | 14 ++++++++++++++ src/VersionInfo.php | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changelogs/4.7.md diff --git a/changelogs/4.7.md b/changelogs/4.7.md new file mode 100644 index 000000000..b450f7cf4 --- /dev/null +++ b/changelogs/4.7.md @@ -0,0 +1,14 @@ +**For Minecraft: Bedrock Edition 1.19.20** + +### Note about API versions +Plugins which don't touch the protocol and compatible with any previous 4.x.y version will also run on these releases and do not need API bumps. +Plugin developers should **only** update their required API to this version if you need the changes in this build. + +**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do. + +# 4.7.0 +Released 9th August 2022. + +## General +- Added support for Minecraft: Bedrock Edition 1.19.20. +- Removed support for older versions. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 3042026f3..f1f141c62 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.6.3"; - public const IS_DEVELOPMENT_BUILD = true; + public const BASE_VERSION = "4.7.0"; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "stable"; private function __construct(){ From e9a1cb7ce5c376fa1ebdee980df8998e658c496e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Aug 2022 19:24:02 +0100 Subject: [PATCH 10/21] 4.7.1 is next --- src/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VersionInfo.php b/src/VersionInfo.php index f1f141c62..af0b03be2 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.7.0"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "4.7.1"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; private function __construct(){ From 8acc5352188918821c5a9c356f1f07483ff88faf Mon Sep 17 00:00:00 2001 From: Dylan T Date: Tue, 9 Aug 2022 19:27:54 +0100 Subject: [PATCH 11/21] ffs --- .github/workflows/discord-release-notify.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml index 94570dc21..210f5c0d9 100644 --- a/.github/workflows/discord-release-notify.yml +++ b/.github/workflows/discord-release-notify.yml @@ -17,6 +17,19 @@ jobs: with: php-version: 8.0 + - name: Restore Composer package cache + uses: actions/cache@v3 + with: + path: | + ~/.cache/composer/files + ~/.cache/composer/vcs + key: "composer-v2-cache-${{ hashFiles('./composer.lock') }}" + restore-keys: | + composer-v2-cache- + + - name: Install Composer dependencies + run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs + - name: Get actual tag name id: tag-name run: echo ::set-output name=TAG_NAME::$(echo "${{ github.ref }}" | sed 's{^refs/tags/{{') From 44e4dabf6e3a455bb4ded288338f7af38c1edfdf Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Aug 2022 17:04:36 +0100 Subject: [PATCH 12/21] Fixed Turtle Master potions giving no effects --- src/item/PotionType.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/item/PotionType.php b/src/item/PotionType.php index 1dab192dc..7ec0f3876 100644 --- a/src/item/PotionType.php +++ b/src/item/PotionType.php @@ -185,13 +185,16 @@ final class PotionType{ new EffectInstance(VanillaEffects::WITHER(), 800, 1) ]), new self("turtle_master", "Turtle Master", fn() => [ - //TODO + new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 3), + new EffectInstance(VanillaEffects::RESISTANCE(), 20 * 20, 2), ]), new self("long_turtle_master", "Long Turtle Master", fn() => [ - //TODO + new EffectInstance(VanillaEffects::SLOWNESS(), 40 * 20, 3), + new EffectInstance(VanillaEffects::RESISTANCE(), 40 * 20, 2), ]), new self("strong_turtle_master", "Strong Turtle Master", fn() => [ - //TODO + new EffectInstance(VanillaEffects::SLOWNESS(), 20 * 20, 5), + new EffectInstance(VanillaEffects::RESISTANCE(), 20 * 20, 3), ]), new self("slow_falling", "Slow Falling", fn() => [ //TODO From 566f5935a306dc5857e083f7d195fcfc2a8219e4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Aug 2022 17:19:47 +0100 Subject: [PATCH 13/21] CraftingManagerFromDataHelper: do not register recipes with unknown outputs fixes #5093 we don't need to check the inputs, since unknown input items shouldn't be obtainable anyway. --- .../CraftingManagerFromDataHelper.php | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/crafting/CraftingManagerFromDataHelper.php b/src/crafting/CraftingManagerFromDataHelper.php index 05612e66d..e91cb4ba6 100644 --- a/src/crafting/CraftingManagerFromDataHelper.php +++ b/src/crafting/CraftingManagerFromDataHelper.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\crafting; use pocketmine\item\Item; +use pocketmine\item\ItemFactory; use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\Utils; use function array_map; @@ -33,6 +34,23 @@ use function json_decode; final class CraftingManagerFromDataHelper{ + /** + * @param Item[] $items + */ + private static function containsUnknownOutputs(array $items) : bool{ + $factory = ItemFactory::getInstance(); + foreach($items as $item){ + if($item->hasAnyDamageValue()){ + throw new \InvalidArgumentException("Recipe outputs must not have wildcard meta values"); + } + if(!$factory->isRegistered($item->getId(), $item->getMeta())){ + return true; + } + } + + return false; + } + public static function make(string $filePath) : CraftingManager{ $recipes = json_decode(Utils::assumeNotFalse(file_get_contents($filePath), "Missing required resource file"), true); if(!is_array($recipes)){ @@ -52,9 +70,13 @@ final class CraftingManagerFromDataHelper{ if($recipeType === null){ continue; } + $output = array_map($itemDeserializerFunc, $recipe["output"]); + if(self::containsUnknownOutputs($output)){ + continue; + } $result->registerShapelessRecipe(new ShapelessRecipe( array_map($itemDeserializerFunc, $recipe["input"]), - array_map($itemDeserializerFunc, $recipe["output"]), + $output, $recipeType )); } @@ -62,10 +84,14 @@ final class CraftingManagerFromDataHelper{ if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics continue; } + $output = array_map($itemDeserializerFunc, $recipe["output"]); + if(self::containsUnknownOutputs($output)){ + continue; + } $result->registerShapedRecipe(new ShapedRecipe( $recipe["shape"], array_map($itemDeserializerFunc, $recipe["input"]), - array_map($itemDeserializerFunc, $recipe["output"]) + $output )); } foreach($recipes["smelting"] as $recipe){ @@ -79,19 +105,30 @@ final class CraftingManagerFromDataHelper{ if($furnaceType === null){ continue; } + $output = Item::jsonDeserialize($recipe["output"]); + if(self::containsUnknownOutputs([$output])){ + continue; + } $result->getFurnaceRecipeManager($furnaceType)->register(new FurnaceRecipe( - Item::jsonDeserialize($recipe["output"]), + $output, Item::jsonDeserialize($recipe["input"])) ); } foreach($recipes["potion_type"] as $recipe){ + $output = Item::jsonDeserialize($recipe["output"]); + if(self::containsUnknownOutputs([$output])){ + continue; + } $result->registerPotionTypeRecipe(new PotionTypeRecipe( Item::jsonDeserialize($recipe["input"]), Item::jsonDeserialize($recipe["ingredient"]), - Item::jsonDeserialize($recipe["output"]) + $output )); } foreach($recipes["potion_container_change"] as $recipe){ + if(!ItemFactory::getInstance()->isRegistered($recipe["output_item_id"])){ + continue; + } $result->registerPotionContainerChangeRecipe(new PotionContainerChangeRecipe( $recipe["input_item_id"], Item::jsonDeserialize($recipe["ingredient"]), From 2fc84f6c676174cf24c6f4e80288ffdb077b02eb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Aug 2022 17:24:43 +0100 Subject: [PATCH 14/21] ItemFactory: treat durables with negative meta as unknown items fixes #5117 --- src/item/ItemFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item/ItemFactory.php b/src/item/ItemFactory.php index eefb5eb95..4a949f843 100644 --- a/src/item/ItemFactory.php +++ b/src/item/ItemFactory.php @@ -472,7 +472,7 @@ class ItemFactory{ if(isset($this->list[$offset = self::getListOffset($id, $meta)])){ $item = clone $this->list[$offset]; }elseif(isset($this->list[$zero = self::getListOffset($id, 0)]) && $this->list[$zero] instanceof Durable){ - if($meta <= $this->list[$zero]->getMaxDurability()){ + if($meta >= 0 && $meta <= $this->list[$zero]->getMaxDurability()){ $item = clone $this->list[$zero]; $item->setDamage($meta); }else{ From 82b9afef77f94d65c237a2918ebf29718a5e6501 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Aug 2022 18:00:52 +0100 Subject: [PATCH 15/21] Allow generating RST permission summaries, to be used on doc.pmmp.io --- tools/generate-permission-doc.php | 101 ++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 18 deletions(-) diff --git a/tools/generate-permission-doc.php b/tools/generate-permission-doc.php index 09f9892a1..0eed2ba63 100644 --- a/tools/generate-permission-doc.php +++ b/tools/generate-permission-doc.php @@ -42,13 +42,23 @@ use const STDERR; require dirname(__DIR__) . '/vendor/autoload.php'; +if(count($argv) > 2){ + fwrite(STDERR, "Required arguments: md|rst\n"); + exit(1); +} +$format = $argv[1] ?? "md"; +if($format !== "md" && $format !== "rst"){ + fwrite(STDERR, "Invalid format, expected either \"md\" or \"rst\"\n"); + exit(1); +} + function markdownify(string $name) : string{ return str_replace(['.', '`', ' '], ['', '', '-'], strtolower($name)); } DefaultPermissions::registerCorePermissions(); $cwd = Utils::assumeNotFalse(getcwd()); -$output = Path::join($cwd, "core-permissions.md"); +$output = Path::join($cwd, "core-permissions.$format"); echo "Writing output to $output\n"; $doc = fopen($output, "wb"); if($doc === false){ @@ -59,36 +69,91 @@ if($doc === false){ $permissions = PermissionManager::getInstance()->getPermissions(); ksort($permissions, SORT_STRING); -fwrite($doc, "# PocketMine-MP Core Permissions\n"); +$title = "PocketMine-MP Core Permissions"; +if($format === "md"){ + fwrite($doc, "# $title\n"); +}else{ + fwrite($doc, "$title\n"); + fwrite($doc, str_repeat("=", strlen($title)) . "\n\n"); +} + fwrite($doc, "Generated from PocketMine-MP " . VersionInfo::VERSION()->getFullVersion() . "\n"); fwrite($doc, "\n"); -fwrite($doc, "| Name | Description | Implied permissions |\n"); -fwrite($doc, "|:-----|:------------|:-------------------:|\n"); +if($format === "md"){ + fwrite($doc, "| Name | Description | Implied permissions |\n"); + fwrite($doc, "|:-----|:------------|:-------------------:|\n"); +}else{ + fwrite($doc, ".. list-table::\n"); + fwrite($doc, " :header-rows: 1\n\n"); + fwrite($doc, " * - Name\n"); + fwrite($doc, " - Description\n"); + fwrite($doc, " - Implied permissions\n"); + fwrite($doc, "\n"); +} foreach($permissions as $permission){ - $link = count($permission->getChildren()) === 0 ? "N/A" : "[Jump](#" . markdownify("Permissions implied by `" . $permission->getName() . "`") . ")"; - fwrite($doc, "| `" . $permission->getName() . "` | " . $permission->getDescription() . " | $link |\n"); + if($format === "md"){ + $link = count($permission->getChildren()) === 0 ? "N/A" : "[Jump](#" . markdownify("Permissions implied by `" . $permission->getName() . "`") . ")"; + fwrite($doc, "| `" . $permission->getName() . "` | " . $permission->getDescription() . " | $link |\n"); + }else{ + fwrite($doc, " * - ``" . $permission->getName() . "``\n"); + fwrite($doc, " - " . $permission->getDescription() . "\n"); + if(count($permission->getChildren()) === 0){ + fwrite($doc, " - N/A\n"); + }else{ + fwrite($doc, " - :ref:`JumpgetName() . ">`\n"); + } + } } fwrite($doc, "\n\n"); -fwrite($doc, "## Implied permissions\n"); -fwrite($doc, "Some permissions automatically grant (or deny) other permissions by default when granted. These are referred to as **implied permissions**.
\n"); -fwrite($doc, "Permissions may imply permissions which in turn imply other permissions (e.g. `pocketmine.group.operator` implies `pocketmine.group.user`, which in turn implies `pocketmine.command.help`).
\n"); -fwrite($doc, "Implied permissions can be overridden by explicit permissions from elsewhere.
\n"); -fwrite($doc, "**Note:** When explicitly denied, implied permissions are inverted. This means that \"granted\" becomes \"denied\" and vice versa.\n"); + +$title = "Implied permissions"; +if($format === "md"){ + fwrite($doc, "## $title\n"); +}else{ + fwrite($doc, "$title\n"); + fwrite($doc, str_repeat("-", strlen($title)) . "\n\n"); +} +$newline = $format === "md" ? "
\n" : "\n\n"; +$code = $format === "md" ? "`" : "``"; +fwrite($doc, "Some permissions automatically grant (or deny) other permissions by default when granted. These are referred to as **implied permissions**.$newline"); +fwrite($doc, "Permissions may imply permissions which in turn imply other permissions (e.g. {$code}pocketmine.group.operator{$code} implies {$code}pocketmine.group.user{$code}, which in turn implies {$code}pocketmine.command.help{$code}).$newline"); +fwrite($doc, "Implied permissions can be overridden by explicit permissions from elsewhere.$newline"); +fwrite($doc, "**Note:** When explicitly denied, implied permissions are inverted. This means that \"granted\" becomes \"denied\" and vice versa.$newline"); fwrite($doc, "\n\n"); foreach($permissions as $permission){ if(count($permission->getChildren()) === 0){ continue; } - fwrite($doc, "### Permissions implied by `" . $permission->getName() . "`\n"); + $title = "Permissions implied by " . $code . $permission->getName() . $code; + if($format === "md"){ + fwrite($doc, "### $title\n"); + }else{ + fwrite($doc, ".. _permissions_implied_by_" . $permission->getName() . ":\n\n"); + fwrite($doc, "$title\n"); + fwrite($doc, str_repeat("~", strlen($title)) . "\n\n"); + } fwrite($doc, "Users granted this permission will also be granted/denied the following permissions implicitly:\n\n"); - fwrite($doc, "| Name | Type |\n"); - fwrite($doc, "|:-----|:----:|\n"); - $children = $permission->getChildren(); - ksort($children, SORT_STRING); - foreach(Utils::stringifyKeys($children) as $childName => $isGranted){ - fwrite($doc, "| `$childName` | " . ($isGranted ? "Granted" : "Denied") . " |\n"); + if($format === "md"){ + fwrite($doc, "| Name | Type |\n"); + fwrite($doc, "|:-----|:----:|\n"); + $children = $permission->getChildren(); + ksort($children, SORT_STRING); + foreach(Utils::stringifyKeys($children) as $childName => $isGranted){ + fwrite($doc, "| `$childName` | " . ($isGranted ? "Granted" : "Denied") . " |\n"); + } + }else{ + fwrite($doc, ".. list-table::\n"); + fwrite($doc, " :header-rows: 1\n\n"); + fwrite($doc, " * - Name\n"); + fwrite($doc, " - Type\n"); + $children = $permission->getChildren(); + ksort($children, SORT_STRING); + foreach(Utils::stringifyKeys($children) as $childName => $isGranted){ + fwrite($doc, " * - ``$childName``\n"); + fwrite($doc, " - " . ($isGranted ? "Granted" : "Denied") . "\n"); + } } fwrite($doc, "\n"); } From 0f8ad8ecf77dea643364e281b6114be11b963236 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Aug 2022 20:47:38 +0100 Subject: [PATCH 16/21] Update permission doc output format --- tools/generate-permission-doc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/generate-permission-doc.php b/tools/generate-permission-doc.php index 0eed2ba63..9dfa15cc7 100644 --- a/tools/generate-permission-doc.php +++ b/tools/generate-permission-doc.php @@ -69,15 +69,16 @@ if($doc === false){ $permissions = PermissionManager::getInstance()->getPermissions(); ksort($permissions, SORT_STRING); -$title = "PocketMine-MP Core Permissions"; +$title = "List of " . VersionInfo::NAME . " core permissions"; if($format === "md"){ fwrite($doc, "# $title\n"); }else{ + fwrite($doc, ".. _corepermissions:\n\n"); fwrite($doc, "$title\n"); fwrite($doc, str_repeat("=", strlen($title)) . "\n\n"); } -fwrite($doc, "Generated from PocketMine-MP " . VersionInfo::VERSION()->getFullVersion() . "\n"); +fwrite($doc, "Generated from " . VersionInfo::NAME . " " . VersionInfo::VERSION()->getFullVersion() . "\n"); fwrite($doc, "\n"); if($format === "md"){ fwrite($doc, "| Name | Description | Implied permissions |\n"); From 15586ed80e122e775130c280e7d56d6ae3d10441 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 12 Aug 2022 21:09:15 +0100 Subject: [PATCH 17/21] Fix CS --- tools/generate-permission-doc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/generate-permission-doc.php b/tools/generate-permission-doc.php index 9dfa15cc7..7d66740aa 100644 --- a/tools/generate-permission-doc.php +++ b/tools/generate-permission-doc.php @@ -35,7 +35,9 @@ use function fopen; use function fwrite; use function getcwd; use function ksort; +use function str_repeat; use function str_replace; +use function strlen; use function strtolower; use const SORT_STRING; use const STDERR; From 464b65b25c29f3c14adc5943b4ef745dc55b9fca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Aug 2022 21:11:11 +0100 Subject: [PATCH 18/21] Bump docker/build-push-action from 3.1.0 to 3.1.1 (#5213) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v3.1.0...v3.1.1) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build-docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index a9e6a2e31..8e1ba493e 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -46,7 +46,7 @@ jobs: run: echo ::set-output name=NAME::$(echo "${GITHUB_REPOSITORY,,}") - name: Build image for tag - uses: docker/build-push-action@v3.1.0 + uses: docker/build-push-action@v3.1.1 with: push: true context: ./pocketmine-mp @@ -59,7 +59,7 @@ jobs: - name: Build image for major tag if: steps.channel.outputs.CHANNEL == 'stable' - uses: docker/build-push-action@v3.1.0 + uses: docker/build-push-action@v3.1.1 with: push: true context: ./pocketmine-mp @@ -72,7 +72,7 @@ jobs: - name: Build image for minor tag if: steps.channel.outputs.CHANNEL == 'stable' - uses: docker/build-push-action@v3.1.0 + uses: docker/build-push-action@v3.1.1 with: push: true context: ./pocketmine-mp @@ -85,7 +85,7 @@ jobs: - name: Build image for latest tag if: steps.channel.outputs.CHANNEL == 'stable' - uses: docker/build-push-action@v3.1.0 + uses: docker/build-push-action@v3.1.1 with: push: true context: ./pocketmine-mp From 14b4644b0300bac69ba97cb14717bf343b35faa5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 14 Aug 2022 17:15:47 +0100 Subject: [PATCH 19/21] Added build_log_url to build_info.json --- .github/workflows/draft-release.yml | 2 +- build/generate-build-info-json.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index edd250384..ceb3b1d9d 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -57,7 +57,7 @@ jobs: echo ::set-output name=PM_VERSION_MD::$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\VersionInfo::BASE_VERSION);') - name: Generate build info - run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} ${{ steps.build-number.outputs.BUILD_NUMBER }} > build_info.json + run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} ${{ steps.build-number.outputs.BUILD_NUMBER }} ${{ github.run_id }} > build_info.json - name: Upload release artifacts uses: actions/upload-artifact@v3 diff --git a/build/generate-build-info-json.php b/build/generate-build-info-json.php index b4e92f7d6..f0ffe7df8 100644 --- a/build/generate-build-info-json.php +++ b/build/generate-build-info-json.php @@ -23,8 +23,8 @@ declare(strict_types=1); require dirname(__DIR__) . '/vendor/autoload.php'; -if(count($argv) !== 5){ - fwrite(STDERR, "required args: "); +if(count($argv) !== 6){ + fwrite(STDERR, "required args: \n"); exit(1); } @@ -40,4 +40,5 @@ echo json_encode([ "details_url" => "https://github.com/$argv[3]/releases/tag/$argv[2]", "download_url" => "https://github.com/$argv[3]/releases/download/$argv[2]/PocketMine-MP.phar", "source_url" => "https://github.com/$argv[3]/tree/$argv[2]", + "build_log_url" => "https://github.com/$argv[3]/actions/runs/$argv[5]", ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR) . "\n"; From 9343a0b80036419df09b7302a76bb5318334818c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 14 Aug 2022 17:19:42 +0100 Subject: [PATCH 20/21] Added build log link to Discord release embed --- .github/workflows/discord-release-embed.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/discord-release-embed.php b/.github/workflows/discord-release-embed.php index 8c6213b83..41ef89878 100644 --- a/.github/workflows/discord-release-embed.php +++ b/.github/workflows/discord-release-embed.php @@ -18,7 +18,7 @@ require dirname(__DIR__, 2) . '/vendor/autoload.php'; /** * @phpstan-return array */ -function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl) : array{ +function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl, string $buildLogUrl) : array{ return [ "embeds" => [ [ @@ -26,7 +26,7 @@ function generateDiscordEmbed(string $version, string $channel, string $descript "description" => << $detailsUrl, "color" => $channel === "stable" ? 0x57ab5a : 0xc69026 @@ -82,11 +82,11 @@ if(!is_array($buildInfoJson)){ $detailsUrl = $buildInfoJson["details_url"]; $sourceUrl = $buildInfoJson["source_url"]; $pharDownloadUrl = $buildInfoJson["download_url"]; - +$buildLogUrl = $buildInfoJson["build_log_url"]; $description = $releaseInfoJson["body"]; -$discordPayload = generateDiscordEmbed($buildInfoJson["base_version"], $buildInfoJson["channel"], $description, $detailsUrl, $sourceUrl, $pharDownloadUrl); +$discordPayload = generateDiscordEmbed($buildInfoJson["base_version"], $buildInfoJson["channel"], $description, $detailsUrl, $sourceUrl, $pharDownloadUrl, $buildLogUrl); $response = Internet::postURL( $hookURL, From 036e06e889427b8701a14338ebc30fca2192aecd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 14 Aug 2022 17:25:55 +0100 Subject: [PATCH 21/21] Revert "Workaround items in blockentity NBT not being processed correctly in 1.19.10" This reverts commit 2b61c025c26394c3293bcc12a2d0b2301cb4c7ee. --- src/network/mcpe/NetworkSession.php | 18 ------------------ .../mcpe/serializer/ChunkSerializer.php | 16 +--------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index da0a1c26a..c1e4e7edd 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace pocketmine\network\mcpe; -use pocketmine\block\tile\Spawnable; use pocketmine\data\bedrock\EffectIdMap; use pocketmine\entity\Attribute; use pocketmine\entity\effect\EffectInstance; @@ -59,7 +58,6 @@ use pocketmine\network\mcpe\handler\PreSpawnPacketHandler; use pocketmine\network\mcpe\handler\ResourcePacksPacketHandler; use pocketmine\network\mcpe\handler\SpawnResponsePacketHandler; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; -use pocketmine\network\mcpe\protocol\BlockActorDataPacket; use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\DisconnectPacket; @@ -961,22 +959,6 @@ class NetworkSession{ try{ $this->queueCompressed($promise); $onCompletion(); - - //TODO: HACK! we send the full tile data here, due to a bug in 1.19.10 which causes items in tiles - //(item frames, lecterns) to not load properly when they are sent in a chunk via the classic chunk - //sending mechanism. We workaround this bug by sending only bare essential data in LevelChunkPacket - //(enough to create the tiles, since BlockActorDataPacket can't create tiles by itself) and then - //send the actual tile properties here. - //TODO: maybe we can stuff these packets inside the cached batch alongside LevelChunkPacket? - $chunk = $currentWorld->getChunk($chunkX, $chunkZ); - if($chunk !== null){ - foreach($chunk->getTiles() as $tile){ - if(!($tile instanceof Spawnable)){ - continue; - } - $this->sendDataPacket(BlockActorDataPacket::create(BlockPosition::fromVector3($tile->getPosition()), $tile->getSerializedSpawnCompound())); - } - } }finally{ $world->timings->syncChunkSend->stopTiming(); } diff --git a/src/network/mcpe/serializer/ChunkSerializer.php b/src/network/mcpe/serializer/ChunkSerializer.php index 493dfc6ab..473ad615d 100644 --- a/src/network/mcpe/serializer/ChunkSerializer.php +++ b/src/network/mcpe/serializer/ChunkSerializer.php @@ -24,11 +24,8 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\serializer; use pocketmine\block\tile\Spawnable; -use pocketmine\block\tile\Tile; -use pocketmine\block\tile\TileFactory; use pocketmine\data\bedrock\BiomeIds; use pocketmine\data\bedrock\LegacyBiomeIdToStringIdMap; -use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\TreeRoot; use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; @@ -41,7 +38,6 @@ use pocketmine\world\format\PalettedBlockArray; use pocketmine\world\format\SubChunk; use function chr; use function count; -use function get_class; use function str_repeat; final class ChunkSerializer{ @@ -129,19 +125,9 @@ final class ChunkSerializer{ public static function serializeTiles(Chunk $chunk) : string{ $stream = new BinaryStream(); - $nbtSerializer = new NetworkNbtSerializer(); foreach($chunk->getTiles() as $tile){ if($tile instanceof Spawnable){ - //TODO: HACK! we send only the bare essentials to create a tile in the chunk itself, due to a bug in - //1.19.10 which causes items in tiles (item frames, lecterns) to not load properly when they are sent in - //a chunk via the classic chunk sending mechanism. We workaround this bug by sendingBlockActorDataPacket - //in NetworkSession to set the actual tile properties after sending the LevelChunkPacket. - $nbt = CompoundTag::create() - ->setString(Tile::TAG_ID, TileFactory::getInstance()->getSaveId(get_class($tile))) - ->setInt(Tile::TAG_X, $tile->getPosition()->getFloorX()) - ->setInt(Tile::TAG_Y, $tile->getPosition()->getFloorY()) - ->setInt(Tile::TAG_Z, $tile->getPosition()->getFloorZ()); - $stream->put($nbtSerializer->write(new TreeRoot($nbt))); + $stream->put($tile->getSerializedSpawnCompound()->getEncodedNbt()); } }