From a4d68fb32bb9b4192944bf29b21ee14aaf3f4ceb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 18:16:46 +0000 Subject: [PATCH 01/27] LegacySkinAdapter: fix some wacky cape handling logic I added checks for length validity locally and ran into some interesting behaviour because of this code. --- .../network/mcpe/protocol/types/LegacySkinAdapter.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php index 676868b3e..e503ee825 100644 --- a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php +++ b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php @@ -31,10 +31,8 @@ use function is_string; class LegacySkinAdapter implements SkinAdapter{ public function toSkinData(Skin $skin) : SkinData{ - $capeData = new SkinImage(32, 64, $skin->getCapeData()); - if($skin->getCapeData() === ""){ - $capeData = new SkinImage(0, 0, $skin->getCapeData()); - } + $capeData = $skin->getCapeData(); + $capeImage = $capeData === "" ? new SkinImage(0, 0, "") : new SkinImage(32, 64, $capeData); $geometryName = $skin->getGeometryName(); if($geometryName === ""){ $geometryName = "geometry.humanoid.custom"; @@ -43,7 +41,7 @@ class LegacySkinAdapter implements SkinAdapter{ $skin->getSkinId(), json_encode(["geometry" => ["default" => $geometryName]]), SkinImage::fromLegacy($skin->getSkinData()), [], - $capeData, + $capeImage, $skin->getGeometryData() ); } From 1a99938e4b5af0295e449379dbdb0a3ffe703efd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 18:26:20 +0000 Subject: [PATCH 02/27] LegacySkinAdapter: clean up nonsensical code ordering --- .../mcpe/protocol/types/LegacySkinAdapter.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php index e503ee825..639e1adcf 100644 --- a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php +++ b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php @@ -47,7 +47,12 @@ class LegacySkinAdapter implements SkinAdapter{ } public function fromSkinData(SkinData $data) : Skin{ - $capeData = $data->getCapeImage()->getData(); + if($data->isPersona()){ + return new Skin("Standard_Custom", str_repeat(random_bytes(3) . "\xff", 2048)); + } + + $capeData = $data->isPersonaCapeOnClassic() ? "" : $data->getCapeImage()->getData(); + $geometryName = ""; $resourcePatch = json_decode($data->getResourcePatch(), true); if(is_array($resourcePatch["geometry"]) && is_string($resourcePatch["geometry"]["default"])){ @@ -55,11 +60,7 @@ class LegacySkinAdapter implements SkinAdapter{ }else{ //TODO: Kick for invalid skin } - if($data->isPersona()){ - return new Skin("Standard_Custom", str_repeat(random_bytes(3) . "\xff", 2048)); - }elseif($data->isPersonaCapeOnClassic()){ - $capeData = ""; - } + return new Skin($data->getSkinId(), $data->getSkinImage()->getData(), $capeData, $geometryName, $data->getGeometryData()); } } From 6b61efcfc8fe2a4bd3cb6353b0626d918cca42d6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 19:49:21 +0000 Subject: [PATCH 03/27] remove unused imports --- src/pocketmine/Server.php | 1 - src/pocketmine/entity/object/FallingBlock.php | 1 - src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php | 1 - .../network/mcpe/protocol/AvailableActorIdentifiersPacket.php | 1 - src/pocketmine/network/mcpe/protocol/PlayerListPacket.php | 1 - .../network/mcpe/protocol/ResourcePackChunkDataPacket.php | 1 - src/pocketmine/network/mcpe/protocol/StartGamePacket.php | 2 -- src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php | 1 - .../network/mcpe/protocol/types/RuntimeBlockMapping.php | 2 -- 9 files changed, 11 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index bcc068d7a..c2ea76c77 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -128,7 +128,6 @@ use function getmypid; use function getopt; use function gettype; use function implode; -use function ini_get; use function ini_set; use function is_array; use function is_bool; diff --git a/src/pocketmine/entity/object/FallingBlock.php b/src/pocketmine/entity/object/FallingBlock.php index 87e408d1f..c96723a61 100644 --- a/src/pocketmine/entity/object/FallingBlock.php +++ b/src/pocketmine/entity/object/FallingBlock.php @@ -34,7 +34,6 @@ use pocketmine\level\Position; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\IntTag; use function abs; -use function floor; use function get_class; class FallingBlock extends Entity{ diff --git a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php index b064ae803..6b8297e75 100644 --- a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php +++ b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php @@ -67,7 +67,6 @@ use pocketmine\network\mcpe\protocol\ShowCreditsPacket; use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket; use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton; -use pocketmine\network\mcpe\protocol\types\SkinData; use pocketmine\Player; use pocketmine\Server; use pocketmine\timings\Timings; diff --git a/src/pocketmine/network/mcpe/protocol/AvailableActorIdentifiersPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableActorIdentifiersPacket.php index e1c3baea7..933b212f7 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableActorIdentifiersPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableActorIdentifiersPacket.php @@ -26,7 +26,6 @@ namespace pocketmine\network\mcpe\protocol; #include use pocketmine\network\mcpe\NetworkSession; -use function base64_decode; use function file_get_contents; class AvailableActorIdentifiersPacket extends DataPacket{ diff --git a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php index f73abb254..b15f7b413 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php @@ -27,7 +27,6 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; -use pocketmine\network\mcpe\protocol\types\SkinData; use pocketmine\network\mcpe\protocol\types\PlayerListEntry; use function count; diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php index 07d34affd..500a878c9 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php @@ -28,7 +28,6 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; -use function strlen; class ResourcePackChunkDataPacket extends DataPacket{ public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET; diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index 8d3611c8f..b3273ddd0 100644 --- a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php @@ -28,9 +28,7 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\math\Vector3; use pocketmine\nbt\NetworkLittleEndianNBTStream; -use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; -use pocketmine\nbt\tag\StringTag; use pocketmine\network\mcpe\NetworkBinaryStream; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\types\PlayerPermissions; diff --git a/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php b/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php index ee46417a9..1393bf48b 100644 --- a/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php +++ b/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\protocol\types; -use pocketmine\entity\Skin; use pocketmine\utils\UUID; class PlayerListEntry{ diff --git a/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php b/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php index 5fedc28b6..5a1bd7141 100644 --- a/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php +++ b/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php @@ -28,8 +28,6 @@ use pocketmine\nbt\NBT; use pocketmine\nbt\NetworkLittleEndianNBTStream; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; -use pocketmine\nbt\tag\StringTag; -use pocketmine\utils\BinaryDataException; use function file_get_contents; use function getmypid; use function json_decode; From 50a4c42f3f20a432aca74e0f79375e63e8eae3af Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 19:53:32 +0000 Subject: [PATCH 04/27] NetworkBinaryStream: fix misplaced import --- src/pocketmine/network/mcpe/NetworkBinaryStream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index 0b6b8a097..b8cd85838 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -38,9 +38,9 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\network\mcpe\protocol\types\CommandOriginData; use pocketmine\network\mcpe\protocol\types\EntityLink; +use pocketmine\network\mcpe\protocol\types\SkinAnimation; use pocketmine\network\mcpe\protocol\types\SkinData; use pocketmine\network\mcpe\protocol\types\SkinImage; -use pocketmine\network\mcpe\protocol\types\SkinAnimation; use pocketmine\network\mcpe\protocol\types\StructureSettings; use pocketmine\utils\BinaryStream; use pocketmine\utils\UUID; From f00c69c5130eb40ddf1926398dbf01848286a1e9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 20:13:02 +0000 Subject: [PATCH 05/27] added missing function imports --- src/pocketmine/network/mcpe/VerifyLoginTask.php | 1 + .../network/mcpe/protocol/AvailableCommandsPacket.php | 1 + .../network/mcpe/protocol/types/LegacySkinAdapter.php | 4 ++++ src/pocketmine/network/mcpe/protocol/types/SkinImage.php | 1 + 4 files changed, 7 insertions(+) diff --git a/src/pocketmine/network/mcpe/VerifyLoginTask.php b/src/pocketmine/network/mcpe/VerifyLoginTask.php index b56f8efe8..620cdae08 100644 --- a/src/pocketmine/network/mcpe/VerifyLoginTask.php +++ b/src/pocketmine/network/mcpe/VerifyLoginTask.php @@ -37,6 +37,7 @@ use function openssl_verify; use function ord; use function str_split; use function strlen; +use function strtr; use function time; use function wordwrap; use const OPENSSL_ALGO_SHA384; diff --git a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php index d4ef733e9..67c2e691a 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\protocol\types\CommandEnum; use pocketmine\network\mcpe\protocol\types\CommandEnumConstraint; use pocketmine\network\mcpe\protocol\types\CommandParameter; use pocketmine\utils\BinaryDataException; +use function array_search; use function count; use function dechex; diff --git a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php index 639e1adcf..e36a9493b 100644 --- a/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php +++ b/src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php @@ -27,6 +27,10 @@ use pocketmine\entity\Skin; use function is_array; use function is_string; +use function json_decode; +use function json_encode; +use function random_bytes; +use function str_repeat; class LegacySkinAdapter implements SkinAdapter{ diff --git a/src/pocketmine/network/mcpe/protocol/types/SkinImage.php b/src/pocketmine/network/mcpe/protocol/types/SkinImage.php index 0c0dea6df..a588184db 100644 --- a/src/pocketmine/network/mcpe/protocol/types/SkinImage.php +++ b/src/pocketmine/network/mcpe/protocol/types/SkinImage.php @@ -22,6 +22,7 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\protocol\types; +use function strlen; class SkinImage{ From 7e98aa1497e50dd4e1efd9ff2e34f337ce739023 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 20:28:02 +0000 Subject: [PATCH 06/27] leveldb: remove usage of multi-import statement this doesn't conform to the code style. --- src/pocketmine/level/format/io/leveldb/LevelDB.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/level/format/io/leveldb/LevelDB.php b/src/pocketmine/level/format/io/leveldb/LevelDB.php index 6c3e5ec7d..10229f49c 100644 --- a/src/pocketmine/level/format/io/leveldb/LevelDB.php +++ b/src/pocketmine/level/format/io/leveldb/LevelDB.php @@ -33,7 +33,12 @@ use pocketmine\level\generator\GeneratorManager; use pocketmine\level\Level; use pocketmine\level\LevelException; use pocketmine\nbt\LittleEndianNBTStream; -use pocketmine\nbt\tag\{ByteTag, CompoundTag, FloatTag, IntTag, LongTag, StringTag}; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\LongTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\utils\Binary; use pocketmine\utils\BinaryStream; From 73d4ff6b52189c0a15ea7a2c9bd57af178d234f2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 21:16:35 +0000 Subject: [PATCH 07/27] more missed function imports --- src/pocketmine/Server.php | 1 + src/pocketmine/plugin/PluginDescription.php | 1 + src/pocketmine/plugin/PluginManager.php | 1 + src/pocketmine/resourcepacks/ZippedResourcePack.php | 1 + src/pocketmine/utils/Utils.php | 3 +++ 5 files changed, 7 insertions(+) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index c2ea76c77..a1e2e6821 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -114,6 +114,7 @@ use function asort; use function assert; use function base64_encode; use function class_exists; +use function cli_set_process_title; use function count; use function define; use function explode; diff --git a/src/pocketmine/plugin/PluginDescription.php b/src/pocketmine/plugin/PluginDescription.php index 7cdd1e95a..153c37752 100644 --- a/src/pocketmine/plugin/PluginDescription.php +++ b/src/pocketmine/plugin/PluginDescription.php @@ -38,6 +38,7 @@ use function strlen; use function strtoupper; use function substr; use function version_compare; +use function yaml_parse; class PluginDescription{ private $map; diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 0c2abdb27..48e8e12a1 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -40,6 +40,7 @@ use pocketmine\timings\TimingsHandler; use pocketmine\utils\Utils; use function array_intersect; use function array_map; +use function array_merge; use function array_pad; use function class_exists; use function count; diff --git a/src/pocketmine/resourcepacks/ZippedResourcePack.php b/src/pocketmine/resourcepacks/ZippedResourcePack.php index 0364ccd37..6a12ad12b 100644 --- a/src/pocketmine/resourcepacks/ZippedResourcePack.php +++ b/src/pocketmine/resourcepacks/ZippedResourcePack.php @@ -34,6 +34,7 @@ use function filesize; use function fopen; use function fread; use function fseek; +use function gettype; use function hash_file; use function implode; diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 5f388c592..c9e36d72c 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -58,6 +58,7 @@ use function is_object; use function is_readable; use function is_string; use function json_decode; +use function ltrim; use function memory_get_usage; use function ob_end_clean; use function ob_get_contents; @@ -72,6 +73,7 @@ use function preg_match_all; use function preg_replace; use function proc_close; use function proc_open; +use function rtrim; use function sha1; use function spl_object_hash; use function str_pad; @@ -82,6 +84,7 @@ use function stripos; use function strlen; use function strpos; use function strtolower; +use function strtr; use function substr; use function sys_get_temp_dir; use function trim; From 95683642774b1896c5de6f09dd528c1d3766d04d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 9 Dec 2019 21:19:15 +0000 Subject: [PATCH 08/27] fix minor formatting issue in SkinAdapterSingleton --- .../network/mcpe/protocol/types/SkinAdapterSingleton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/network/mcpe/protocol/types/SkinAdapterSingleton.php b/src/pocketmine/network/mcpe/protocol/types/SkinAdapterSingleton.php index f749752bb..b92cdf0df 100644 --- a/src/pocketmine/network/mcpe/protocol/types/SkinAdapterSingleton.php +++ b/src/pocketmine/network/mcpe/protocol/types/SkinAdapterSingleton.php @@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol\types; /** * Accessor for SkinAdapter -*/ + */ class SkinAdapterSingleton{ /** @var SkinAdapter|null */ private static $skinAdapter = null; From e6c3b0fc0da2f7920432a6b0f568073c0a29a043 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 18:32:22 +0000 Subject: [PATCH 09/27] Changes for 1.14 there are no protocol changes in 1.14 that matter; the reason the protocol version has been bumped is because of new blocks, items, mobs and recipes. --- src/pocketmine/network/mcpe/protocol/ProtocolInfo.php | 6 +++--- src/pocketmine/resources/vanilla | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index 242fe0695..0161fa03d 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -39,15 +39,15 @@ interface ProtocolInfo{ /** * Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 388; + public const CURRENT_PROTOCOL = 389; /** * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.13.0'; + public const MINECRAFT_VERSION = 'v1.14.0'; /** * Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.13.0'; + public const MINECRAFT_VERSION_NETWORK = '1.14.0'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; diff --git a/src/pocketmine/resources/vanilla b/src/pocketmine/resources/vanilla index a38b42788..1bda8f70e 160000 --- a/src/pocketmine/resources/vanilla +++ b/src/pocketmine/resources/vanilla @@ -1 +1 @@ -Subproject commit a38b42788883fa2094f67874f15594044be1ac4d +Subproject commit 1bda8f70e68280d18444ba92db775587376c4d8d From a386ff8ce768c34b5d2e67c6971a51556a507690 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 18:35:03 +0000 Subject: [PATCH 10/27] Release 3.11.0 --- changelogs/3.11.md | 11 +++++++++++ src/pocketmine/VersionInfo.php | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelogs/3.11.md diff --git a/changelogs/3.11.md b/changelogs/3.11.md new file mode 100644 index 000000000..ff5fc0931 --- /dev/null +++ b/changelogs/3.11.md @@ -0,0 +1,11 @@ +**For Minecraft: Bedrock Edition 1.14.0** + +### Note about API versions +Plugins which don't touch the protocol and compatible with any previous 3.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. + +# 3.11.0 +- Added support for Minecraft: Bedrock Edition 1.14.0 +- Removed compatibility with 1.13.0 diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index 22776db77..767131e76 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -30,6 +30,6 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; -const BASE_VERSION = "3.10.2"; -const IS_DEVELOPMENT_BUILD = true; +const BASE_VERSION = "3.11.0"; +const IS_DEVELOPMENT_BUILD = false; const BUILD_NUMBER = 0; From 833f3e574b6de7e7472f3d8284cbcc15fc23d93c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 18:35:03 +0000 Subject: [PATCH 11/27] 3.11.1 is next --- src/pocketmine/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index 767131e76..6ef093360 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -30,6 +30,6 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; -const BASE_VERSION = "3.11.0"; -const IS_DEVELOPMENT_BUILD = false; +const BASE_VERSION = "3.11.1"; +const IS_DEVELOPMENT_BUILD = true; const BUILD_NUMBER = 0; From 0196aa21d792d36c6086349417702522ff5a350e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 20:19:17 +0000 Subject: [PATCH 12/27] updated BedrockData submodule, close #3222, close #3223 --- src/pocketmine/resources/vanilla | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/resources/vanilla b/src/pocketmine/resources/vanilla index 1bda8f70e..cc132c80d 160000 --- a/src/pocketmine/resources/vanilla +++ b/src/pocketmine/resources/vanilla @@ -1 +1 @@ -Subproject commit 1bda8f70e68280d18444ba92db775587376c4d8d +Subproject commit cc132c80dd9d76a44e4b0a360e85e8e28bba8956 From 40a2211a5a93af7a587debb4efed2332f564193c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 20:20:26 +0000 Subject: [PATCH 13/27] Release 3.11.1 --- changelogs/3.11.md | 3 +++ src/pocketmine/VersionInfo.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelogs/3.11.md b/changelogs/3.11.md index ff5fc0931..31bf75d07 100644 --- a/changelogs/3.11.md +++ b/changelogs/3.11.md @@ -9,3 +9,6 @@ Plugin developers should **only** update their required API to this version if y # 3.11.0 - Added support for Minecraft: Bedrock Edition 1.14.0 - Removed compatibility with 1.13.0 + +# 3.11.1 +- Fixed blocks with incorrect properties when placed or interacted with. \ No newline at end of file diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index 6ef093360..cff8c1329 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -31,5 +31,5 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; const BASE_VERSION = "3.11.1"; -const IS_DEVELOPMENT_BUILD = true; +const IS_DEVELOPMENT_BUILD = false; const BUILD_NUMBER = 0; From 3c9af56e066948b747a089199544103c4db3eeeb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 20:20:26 +0000 Subject: [PATCH 14/27] 3.11.2 is next --- src/pocketmine/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index cff8c1329..a8e900838 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -30,6 +30,6 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; -const BASE_VERSION = "3.11.1"; -const IS_DEVELOPMENT_BUILD = false; +const BASE_VERSION = "3.11.2"; +const IS_DEVELOPMENT_BUILD = true; const BUILD_NUMBER = 0; From 494f8e82516b66da2416692afa90023c69db5f71 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 22:39:40 +0000 Subject: [PATCH 15/27] login: fixed missing base64_decode() for animation images --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 52dcb3994..3867e9aa1 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1921,7 +1921,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $animations = []; foreach($packet->clientData["AnimatedImageData"] as $animation){ - $animations[] = new SkinAnimation(new SkinImage($animation["ImageHeight"], $animation["ImageWidth"], $animation["Image"]), $animation["Type"], $animation["Frames"]); + $animations[] = new SkinAnimation(new SkinImage($animation["ImageHeight"], $animation["ImageWidth"], base64_decode($animation["Image"], true)), $animation["Type"], $animation["Frames"]); } $skinData = new SkinData( From 1171bae691080488d5a04b0a6051f5159e4bb435 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 22:40:05 +0000 Subject: [PATCH 16/27] login: read the correct key SkinAnimationData --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 3867e9aa1..16451d733 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1931,7 +1931,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $animations, new SkinImage($packet->clientData["CapeImageHeight"], $packet->clientData["CapeImageWidth"], base64_decode($packet->clientData["CapeData"] ?? "")), base64_decode($packet->clientData["SkinGeometryData"] ?? ""), - base64_decode($packet->clientData["AnimationData"] ?? ""), + base64_decode($packet->clientData["SkinAnimationData"] ?? ""), $packet->clientData["PremiumSkin"] ?? false, $packet->clientData["PersonaSkin"] ?? false, $packet->clientData["CapeOnClassicSkin"] ?? false, From dbca36e5e289169deaabb836d5bba9c106fa5564 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Dec 2019 22:45:14 +0000 Subject: [PATCH 17/27] SkinImage: throw on wrong data length --- src/pocketmine/network/mcpe/protocol/types/SkinImage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pocketmine/network/mcpe/protocol/types/SkinImage.php b/src/pocketmine/network/mcpe/protocol/types/SkinImage.php index a588184db..fcb0c966f 100644 --- a/src/pocketmine/network/mcpe/protocol/types/SkinImage.php +++ b/src/pocketmine/network/mcpe/protocol/types/SkinImage.php @@ -34,6 +34,9 @@ class SkinImage{ private $data; public function __construct(int $height, int $width, string $data){ + if(($expected = $height * $width * 4) !== ($actual = strlen($data))){ + throw new \InvalidArgumentException("Data should be exactly $expected bytes, got $actual bytes"); + } $this->height = $height; $this->width = $width; $this->data = $data; From 6127a02a8b32487f7f5951dbc507066079ebb8d3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 10:43:45 +0000 Subject: [PATCH 18/27] phpstan 0.12.2 --- tests/phpstan/configs/phpstan-bugs.neon | 6 ------ tests/travis.sh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 696fcc8ab..6e3312bd8 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -25,9 +25,3 @@ parameters: message: "#^Offset \\(int\\|string\\) does not exist on array\\(\\)\\.$#" count: 1 path: ../../../src/pocketmine/MemoryManager.php - - - - message: "#^Array \\(array\\) does not accept key int\\.$#" - count: 1 - path: ../../../src/pocketmine/plugin/PluginDescription.php - diff --git a/tests/travis.sh b/tests/travis.sh index ba90d4a19..ee5053262 100755 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -21,7 +21,7 @@ if [ $? -ne 0 ]; then exit 1 fi -[ ! -f phpstan.phar ] && echo "Downloading PHPStan..." && curl -sSLO https://github.com/phpstan/phpstan/releases/download/0.12.0/phpstan.phar +[ ! -f phpstan.phar ] && echo "Downloading PHPStan..." && curl -sSLO https://github.com/phpstan/phpstan/releases/download/0.12.2/phpstan.phar "$PHP_BINARY" phpstan.phar analyze --no-progress --memory-limit=2G || exit 1 echo "PHPStan scan succeeded" From b3cfa5a3a098da106fa02c7a5cc11459ac7b84f6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 11:48:34 +0000 Subject: [PATCH 19/27] TimingsHandler: use weak comparison for stopTiming start check this could be an int or float, and 0 !== 0.0. --- src/pocketmine/timings/TimingsHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/timings/TimingsHandler.php b/src/pocketmine/timings/TimingsHandler.php index 4018ee730..87a6100c5 100644 --- a/src/pocketmine/timings/TimingsHandler.php +++ b/src/pocketmine/timings/TimingsHandler.php @@ -168,7 +168,7 @@ class TimingsHandler{ public function stopTiming(){ if(self::$enabled){ - if(--$this->timingDepth !== 0 or $this->start === 0){ + if(--$this->timingDepth !== 0 or $this->start == 0){ return; } From 73c5fe5cf9a3311e8152114654a432101cd0cd52 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 11:58:00 +0000 Subject: [PATCH 20/27] BaseInventory: correctly annotate content type of slots field fixes warnings on phpstan level 4 --- src/pocketmine/inventory/BaseInventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 4f64680a2..4702f90ee 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -46,7 +46,7 @@ abstract class BaseInventory implements Inventory{ protected $name; /** @var string */ protected $title; - /** @var \SplFixedArray|Item[] */ + /** @var \SplFixedArray|(Item|null)[] */ protected $slots; /** @var Player[] */ protected $viewers = []; From b8778cb791edfa95dd76ea08bc4ea0a25c78a5a9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 11:59:12 +0000 Subject: [PATCH 21/27] LevelProvider: fix doc comment of ::generate() this raised false positives on phpstan level 4 --- src/pocketmine/level/format/io/LevelProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/format/io/LevelProvider.php b/src/pocketmine/level/format/io/LevelProvider.php index 2854f0e38..5fa272c17 100644 --- a/src/pocketmine/level/format/io/LevelProvider.php +++ b/src/pocketmine/level/format/io/LevelProvider.php @@ -71,7 +71,7 @@ interface LevelProvider{ * @param string $name * @param int $seed * @param string $generator - * @param array[] $options + * @param array $options */ public static function generate(string $path, string $name, int $seed, string $generator, array $options = []); From a9fafbc5eb6f3b3d69d6fd21a2b46d656710a3c5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 11:59:41 +0000 Subject: [PATCH 22/27] BanEntry: remove nullable return from parseDate() this function never returns null --- src/pocketmine/permission/BanEntry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/permission/BanEntry.php b/src/pocketmine/permission/BanEntry.php index 7c8cbf3ab..addf5287a 100644 --- a/src/pocketmine/permission/BanEntry.php +++ b/src/pocketmine/permission/BanEntry.php @@ -136,10 +136,10 @@ class BanEntry{ /** * @param string $date * - * @return \DateTime|null + * @return \DateTime * @throws \RuntimeException */ - private static function parseDate(string $date) : ?\DateTime{ + private static function parseDate(string $date) : \DateTime{ $datetime = \DateTime::createFromFormat(self::$format, $date); if(!($datetime instanceof \DateTime)){ throw new \RuntimeException("Error parsing date for BanEntry: " . implode(", ", \DateTime::getLastErrors()["errors"])); From 26230c1f9bf6bb1cd9cc22ea1b98b2a8efd3a4d1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 12:17:52 +0000 Subject: [PATCH 23/27] Player: don't report never-played for a disconnected player this should catch fire like everything else does. --- src/pocketmine/Player.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 16451d733..a76add108 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -464,11 +464,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } public function getFirstPlayed(){ - return $this->namedtag instanceof CompoundTag ? $this->namedtag->getLong("firstPlayed", 0, true) : null; + return $this->namedtag->getLong("firstPlayed", 0, true); } public function getLastPlayed(){ - return $this->namedtag instanceof CompoundTag ? $this->namedtag->getLong("lastPlayed", 0, true) : null; + return $this->namedtag->getLong("lastPlayed", 0, true); } public function hasPlayedBefore() : bool{ From 62069bc7af73595b11e118ae1e596e9ec4ffa733 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 12:18:35 +0000 Subject: [PATCH 24/27] Level: fix return type content doc comment for getAdjacentChunks() --- src/pocketmine/level/Level.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 59754eb92..57b16f5bb 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2442,7 +2442,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $x * @param int $z * - * @return Chunk[] + * @return (Chunk|null)[] */ public function getAdjacentChunks(int $x, int $z) : array{ $result = []; From 92be8c8ec0e978be291b39bedc806910829c56ff Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 12:19:54 +0000 Subject: [PATCH 25/27] PopulationTask: don't assume anything about TLS return values while these SHOULD be what we say they are, it's possible for something else to overwrite them with junk and make the server catch fire. --- src/pocketmine/level/generator/PopulationTask.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pocketmine/level/generator/PopulationTask.php b/src/pocketmine/level/generator/PopulationTask.php index 007a6f87f..d061c415b 100644 --- a/src/pocketmine/level/generator/PopulationTask.php +++ b/src/pocketmine/level/generator/PopulationTask.php @@ -56,11 +56,9 @@ class PopulationTask extends AsyncTask{ } public function onRun(){ - /** @var SimpleChunkManager $manager */ $manager = $this->getFromThreadStore("generation.level{$this->levelId}.manager"); - /** @var Generator $generator */ $generator = $this->getFromThreadStore("generation.level{$this->levelId}.generator"); - if($manager === null or $generator === null){ + if(!($manager instanceof SimpleChunkManager) or !($generator instanceof Generator)){ $this->state = false; return; } From 46930b98b774e2b2f9c00e883f79eba95d0ff57b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 12:59:01 +0000 Subject: [PATCH 26/27] Timings: add a dedicated field for checking initialization --- src/pocketmine/timings/Timings.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/timings/Timings.php b/src/pocketmine/timings/Timings.php index a8d1e646c..5192728f5 100644 --- a/src/pocketmine/timings/Timings.php +++ b/src/pocketmine/timings/Timings.php @@ -31,6 +31,8 @@ use pocketmine\tile\Tile; use function dechex; abstract class Timings{ + /** @var bool */ + private static $initialized = false; /** @var TimingsHandler */ public static $fullTickTimer; @@ -104,9 +106,10 @@ abstract class Timings{ public static $pluginTaskTimingMap = []; public static function init(){ - if(self::$serverTickTimer instanceof TimingsHandler){ + if(self::$initialized){ return; } + self::$initialized = true; self::$fullTickTimer = new TimingsHandler("Full Server Tick"); self::$serverTickTimer = new TimingsHandler("** Full Server Tick", self::$fullTickTimer); From 70c3008b7b2bad4aff51abc629add73bb0b17d07 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Dec 2019 13:00:57 +0000 Subject: [PATCH 27/27] phpstan: green on level 4 --- phpstan.neon.dist | 4 +- tests/phpstan/configs/debug-const-checks.neon | 21 +++++++++ tests/phpstan/configs/phpstan-bugs.neon | 44 +++++++++++++++++++ .../phpstan/configs/runtime-type-checks.neon | 31 +++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 tests/phpstan/configs/debug-const-checks.neon create mode 100644 tests/phpstan/configs/runtime-type-checks.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 170897410..c8556a7fd 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,12 +1,14 @@ includes: + - tests/phpstan/configs/debug-const-checks.neon - tests/phpstan/configs/gc-hacks.neon - tests/phpstan/configs/optional-com-dotnet.neon - tests/phpstan/configs/optional-leveldb.neon - tests/phpstan/configs/phpstan-bugs.neon - tests/phpstan/configs/pthreads-bugs.neon + - tests/phpstan/configs/runtime-type-checks.neon parameters: - level: 3 + level: 4 autoload_files: - tests/phpstan/bootstrap.php - src/pocketmine/PocketMine.php diff --git a/tests/phpstan/configs/debug-const-checks.neon b/tests/phpstan/configs/debug-const-checks.neon new file mode 100644 index 000000000..bfe2fa5c6 --- /dev/null +++ b/tests/phpstan/configs/debug-const-checks.neon @@ -0,0 +1,21 @@ +parameters: + ignoreErrors: + - + message: "#^If condition is always true\\.$#" + count: 1 + path: ../../../src/pocketmine/Server.php + + - + message: "#^Ternary operator condition is always true\\.$#" + count: 1 + path: ../../../src/pocketmine/Server.php + + - + message: "#^If condition is always false\\.$#" + count: 1 + path: ../../../src/pocketmine/updater/AutoUpdater.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: ../../../src/pocketmine/updater/AutoUpdater.php diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 6e3312bd8..2efbbb37b 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -25,3 +25,47 @@ parameters: message: "#^Offset \\(int\\|string\\) does not exist on array\\(\\)\\.$#" count: 1 path: ../../../src/pocketmine/MemoryManager.php + + - + message: "#^Comparison operation \"\\>\\=\" between 0 and 2 is always false\\.$#" + count: 1 + path: ../../../src/pocketmine/block/Liquid.php + + - + #adjacentSources comparison FP + message: "#^If condition is always false\\.$#" + count: 1 + path: ../../../src/pocketmine/block/Liquid.php + + - + #$class::NETWORK_ID false positive + message: "#^Strict comparison using \\!\\=\\= between \\-1 and \\-1 will always evaluate to false\\.$#" + count: 1 + path: ../../../src/pocketmine/entity/Entity.php + + - + message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#" + count: 1 + path: ../../../src/pocketmine/entity/projectile/Projectile.php + + - + message: "#^Strict comparison using \\=\\=\\= between int\\ and 4 will always evaluate to false\\.$#" + count: 1 + path: ../../../src/pocketmine/level/Level.php + + - + message: "#^Instanceof between int and PharFileInfo will always evaluate to false\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PharPluginLoader.php + + - + #ReflectionFunction::getClosureThis() should be nullable + message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" + count: 1 + path: ../../../src/pocketmine/utils/Utils.php + + - + #ReflectionFunction::getClosureScopeClass() should be nullable + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: ../../../src/pocketmine/utils/Utils.php diff --git a/tests/phpstan/configs/runtime-type-checks.neon b/tests/phpstan/configs/runtime-type-checks.neon new file mode 100644 index 000000000..7d48cacd9 --- /dev/null +++ b/tests/phpstan/configs/runtime-type-checks.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - + #::add() / ::remove() thread parameter + message: "#^If condition is always true\\.$#" + count: 2 + path: ../../../src/pocketmine/ThreadManager.php + + - + #::get() tags parameter + message: "#^If condition is always false\\.$#" + count: 1 + path: ../../../src/pocketmine/item/ItemFactory.php + + - + #::get() tags parameter + message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#" + count: 1 + path: ../../../src/pocketmine/item/ItemFactory.php + + - + #::get() tags parameter + message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" + count: 1 + path: ../../../src/pocketmine/item/ItemFactory.php + + - + #->sendBlocks() blocks parameter + message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" + count: 2 + path: ../../../src/pocketmine/level/Level.php