From 01ffe8bf578d8ad7b63ebffdf293adfd3fd9383e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 28 Mar 2021 18:14:40 +0100 Subject: [PATCH 1/5] Updated build/php submodule to pmmp/php-build-scripts@c64baa0f1cef695df7ed564e82e02f0399c0ba14 --- build/php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/php b/build/php index 60194e8b1..c64baa0f1 160000 --- a/build/php +++ b/build/php @@ -1 +1 @@ -Subproject commit 60194e8b147b6c57cbc4d3abc4c21ac5d621e802 +Subproject commit c64baa0f1cef695df7ed564e82e02f0399c0ba14 From 3b3fb5e6627b7fcaa054711f4c6aa4c4d5948fe8 Mon Sep 17 00:00:00 2001 From: Ali <47182802+UnknownOre@users.noreply.github.com> Date: Sun, 28 Mar 2021 19:53:46 +0200 Subject: [PATCH 2/5] fix ItemFrames (#4101) removing items from item frames was broken due to behavioural changes in 1.16.210. --- src/pocketmine/Player.php | 10 ++++++++++ tests/phpstan/configs/l8-baseline.neon | 12 ++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b59da0c12..9a4a49841 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2936,6 +2936,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->inventory->sendHeldItem($this); break; } + + $tile = $this->level->getTile($pos); + if($tile instanceof ItemFrame and $tile->hasItem()){ + if (lcg_value() <= $tile->getItemDropChance()){ + $this->level->dropItem($tile->getBlock(), $tile->getItem()); + } + $tile->setItem(null); + $tile->setItemRotation(0); + break; + } $block = $target->getSide($packet->face); if($block->getId() === Block::FIRE){ diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 05c285760..befa66e0d 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -147,7 +147,7 @@ parameters: - message: "#^Cannot call method getTile\\(\\) on pocketmine\\\\level\\\\Level\\|null\\.$#" - count: 2 + count: 3 path: ../../../src/pocketmine/Player.php - @@ -165,6 +165,11 @@ parameters: count: 3 path: ../../../src/pocketmine/Player.php + - + message: "#^Cannot call method dropItem\\(\\) on pocketmine\\\\level\\\\Level\\|null\\.$#" + count: 4 + path: ../../../src/pocketmine/Player.php + - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\level\\\\Level\\|null\\.$#" count: 1 @@ -175,11 +180,6 @@ parameters: count: 3 path: ../../../src/pocketmine/Player.php - - - message: "#^Cannot call method dropItem\\(\\) on pocketmine\\\\level\\\\Level\\|null\\.$#" - count: 3 - path: ../../../src/pocketmine/Player.php - - message: "#^Cannot call method getTileAt\\(\\) on pocketmine\\\\level\\\\Level\\|null\\.$#" count: 1 From e42a691da94d667f0367cedc17775cf20e081990 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 28 Mar 2021 19:02:51 +0100 Subject: [PATCH 3/5] Strip trailing whitespace --- build/make-release.php | 2 +- src/pocketmine/Player.php | 2 +- src/pocketmine/network/upnp/UPnP.php | 2 +- src/pocketmine/wizard/SetupWizard.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/make-release.php b/build/make-release.php index 2cb13f169..d499ff3f6 100644 --- a/build/make-release.php +++ b/build/make-release.php @@ -71,7 +71,7 @@ function main(array $argv) : void{ $versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php'; replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false); - + echo "please add appropriate notes to the changelog and press enter..."; fgets(STDIN); system('git add "' . dirname(__DIR__) . '/changelogs"'); diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 9a4a49841..2237ac36d 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2936,7 +2936,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->inventory->sendHeldItem($this); break; } - + $tile = $this->level->getTile($pos); if($tile instanceof ItemFrame and $tile->hasItem()){ if (lcg_value() <= $tile->getItemDropChance()){ diff --git a/src/pocketmine/network/upnp/UPnP.php b/src/pocketmine/network/upnp/UPnP.php index 54d5a824c..b1e99e013 100644 --- a/src/pocketmine/network/upnp/UPnP.php +++ b/src/pocketmine/network/upnp/UPnP.php @@ -244,7 +244,7 @@ abstract class UPnP{ '' . '' . '' . $body . ''; - + $headers = [ 'Content-Type: text/xml', 'SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping"' diff --git a/src/pocketmine/wizard/SetupWizard.php b/src/pocketmine/wizard/SetupWizard.php index 998080ad3..782005bc2 100644 --- a/src/pocketmine/wizard/SetupWizard.php +++ b/src/pocketmine/wizard/SetupWizard.php @@ -221,7 +221,7 @@ LICENSE; $config->save(); } - + private function printIpDetails() : void{ $this->message($this->lang->get("ip_get")); From 34c2b62ffe6f391e755203954e3b76478ce5ea29 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 28 Mar 2021 19:12:18 +0100 Subject: [PATCH 4/5] Remove unused import --- src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php index 351582d47..1affe2cb5 100644 --- a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php @@ -28,7 +28,6 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\inventory\FurnaceRecipe; use pocketmine\inventory\ShapedRecipe; use pocketmine\inventory\ShapelessRecipe; -use pocketmine\item\Item; use pocketmine\item\ItemFactory; use pocketmine\network\mcpe\convert\ItemTranslator; use pocketmine\network\mcpe\NetworkBinaryStream; From 5c41f79be4b99acec7ebdd79af4e91bdfd45c779 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 28 Mar 2021 19:21:41 +0100 Subject: [PATCH 5/5] Added php-cs-fixer configuration this is by no means a complete code style guide, but it fixes a lot of common issues that show up, particularly in PRs. --- .php_cs | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .php_cs diff --git a/.php_cs b/.php_cs new file mode 100644 index 000000000..48c5278b0 --- /dev/null +++ b/.php_cs @@ -0,0 +1,71 @@ +in(__DIR__ . '/src') + ->in(__DIR__ . '/build') + ->in(__DIR__ . '/tests') + ->notPath('plugins/DevTools') + ->notPath('preprocessor') + ->notContains('#ifndef COMPILE') //preprocessor will break if these are changed + ->notName('PocketMine.php'); + +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + 'align_multiline_comment' => [ + 'comment_type' => 'phpdocs_only' + ], + 'array_indentation' => true, + 'array_syntax' => [ + 'syntax' => 'short' + ], + 'blank_line_after_namespace' => true, + 'blank_line_after_opening_tag' => true, + 'blank_line_before_statement' => [ + 'statements' => [ + 'declare' + ] + ], + 'cast_spaces' => [ + 'space' => 'single' + ], + 'concat_space' => [ + 'spacing' => 'one' + ], + 'declare_strict_types' => true, + 'elseif' => true, + 'global_namespace_import' => [ + 'import_constants' => true, + 'import_functions' => true, + 'import_classes' => null, + ], + 'indentation_type' => true, + 'native_function_invocation' => [ + 'scope' => 'namespaced' + ], + 'no_closing_tag' => true, + 'no_empty_phpdoc' => true, + 'no_extra_blank_lines' => true, + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + ], + 'no_trailing_whitespace' => true, + 'no_trailing_whitespace_in_comment' => true, + 'no_whitespace_in_blank_line' => true, + 'no_unused_imports' => true, + 'ordered_imports' => [ + 'imports_order' => [ + 'class', + 'function', + 'const', + ], + 'sort_algorithm' => 'alpha' + ], + 'phpdoc_trim' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'single_import_per_statement' => true, + 'strict_param' => true, + ]) + ->setFinder($finder) + ->setIndent("\t") + ->setLineEnding("\n");