From ad8132ae113d4dac5c702237134266655e861f71 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 May 2022 14:04:38 +0100 Subject: [PATCH 01/32] Bump build/php from `7b357f8` to `f5d7b45` (#5004) Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `7b357f8` to `f5d7b45`. - [Release notes](https://github.com/pmmp/php-build-scripts/releases) - [Commits](https://github.com/pmmp/php-build-scripts/compare/7b357f8cf9b2d2ee3a9ad247cdc76c8ad62337f9...f5d7b45990152f5b153412a78f82cfeb9c8c86b7) --- updated-dependencies: - dependency-name: build/php dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/php b/build/php index 7b357f8cf..f5d7b4599 160000 --- a/build/php +++ b/build/php @@ -1 +1 @@ -Subproject commit 7b357f8cf9b2d2ee3a9ad247cdc76c8ad62337f9 +Subproject commit f5d7b45990152f5b153412a78f82cfeb9c8c86b7 From 6e372d9e36956c2a6324bb93033e667c94b220f1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 May 2022 14:54:29 +0100 Subject: [PATCH 02/32] Entity: fixed setNameTagVisible not having immediately visible effect --- src/entity/Entity.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 1ca59df1d..2c5adbe98 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -282,6 +282,7 @@ abstract class Entity{ public function setNameTagVisible(bool $value = true) : void{ $this->nameTagVisible = $value; + $this->networkPropertiesDirty = true; } public function setNameTagAlwaysVisible(bool $value = true) : void{ From a6299b0927c1254fc482bf03f56742be0a4fb7f2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 May 2022 15:52:25 +0100 Subject: [PATCH 03/32] pocketmine.yml: moar docs for command aliases hidden features --- resources/pocketmine.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/pocketmine.yml b/resources/pocketmine.yml index 1b22c9e80..f922cb225 100644 --- a/resources/pocketmine.yml +++ b/resources/pocketmine.yml @@ -195,6 +195,12 @@ aliases: #kill: [suicide, say "I tried to kill $1"] ## `kill alex` -> `suicide` + `say "I tried to kill alex"` #giverandom: [give $1 $2, say "Someone has just received a $2!"] ## `giverandom alex diamond` -> `give alex diamond` + `say "Someone has just received a diamond!"` + ##To make arguments mandatory (so that the command fails if they are not provided), use $$, e.g. $$1, $$2: + #makeadmin: [op $$1] ## `makeadmin alex` -> `op alex`, `makeadmin` with no arguments = error + + ##To pass through a range of arguments, put a - (hyphen) after the index: + #tpalias: [tp $1-] ## `tpalias 256 70 256` -> `tp 256 70 256` - this passes arguments 1 and everything after it to the `tp` command + ##To change an existing command alias and make it do something else: #tp: [suicide] From f4d71d0b483942107f2cbbc6b2bd45ca1c362e0b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 May 2022 21:04:38 +0100 Subject: [PATCH 04/32] FormattedCommandAlias: reduce complexity of buildCommand() --- src/command/FormattedCommandAlias.php | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/command/FormattedCommandAlias.php b/src/command/FormattedCommandAlias.php index ca8908897..80590d58c 100644 --- a/src/command/FormattedCommandAlias.php +++ b/src/command/FormattedCommandAlias.php @@ -117,18 +117,7 @@ class FormattedCommandAlias extends Command{ throw new \InvalidArgumentException("Missing required argument " . ($position + 1)); } - $replacement = ""; - if($rest && $position < count($args)){ - for($i = $position, $c = count($args); $i < $c; ++$i){ - if($i !== $position){ - $replacement .= " "; - } - - $replacement .= $args[$i]; - } - }elseif($position < count($args)){ - $replacement .= $args[$position]; - } + $replacement = self::buildReplacement($args, $position, $rest); $formatString = substr($formatString, 0, $start) . $replacement . substr($formatString, $end); @@ -143,4 +132,25 @@ class FormattedCommandAlias extends Command{ private static function inRange(int $i, int $j, int $k) : bool{ return $i >= $j && $i <= $k; } + + /** + * @param string[] $args + * @phpstan-param list $args + */ + private static function buildReplacement(array $args, int $position, bool $rest) : string{ + $replacement = ""; + if($rest && $position < count($args)){ + for($i = $position, $c = count($args); $i < $c; ++$i){ + if($i !== $position){ + $replacement .= " "; + } + + $replacement .= $args[$i]; + } + }elseif($position < count($args)){ + $replacement .= $args[$position]; + } + + return $replacement; + } } From a3538723270a5971f06b3be0392def359fa62c68 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 May 2022 21:16:13 +0100 Subject: [PATCH 05/32] FormattedCommandAlias: match placeholders using regex --- src/command/FormattedCommandAlias.php | 77 ++++++++++++--------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/src/command/FormattedCommandAlias.php b/src/command/FormattedCommandAlias.php index 80590d58c..13281a8eb 100644 --- a/src/command/FormattedCommandAlias.php +++ b/src/command/FormattedCommandAlias.php @@ -26,12 +26,20 @@ namespace pocketmine\command; use pocketmine\Server; use pocketmine\utils\TextFormat; use function count; -use function ord; +use function preg_match; use function strlen; use function strpos; use function substr; class FormattedCommandAlias extends Command{ + /** + * - matches a $ + * - captures an optional second $ to indicate required/optional + * - captures a series of digits which don't start with a 0 + * - captures an optional - to indicate variadic + */ + private const FORMAT_STRING_REGEX = '/\G\$(\$)?((?!0)+\d+)(-)?/'; + /** @var string[] */ private array $formatStrings = []; @@ -68,50 +76,21 @@ class FormattedCommandAlias extends Command{ * @param string[] $args */ private function buildCommand(string $formatString, array $args) : string{ - $index = strpos($formatString, '$'); - while($index !== false){ + $index = 0; + while(($index = strpos($formatString, '$', $index)) !== false){ $start = $index; if($index > 0 && $formatString[$start - 1] === "\\"){ $formatString = substr($formatString, 0, $start - 1) . substr($formatString, $start); - $index = strpos($formatString, '$', $index); + //offset is now pointing at the next character because we just deleted the \ continue; } - $required = false; - if($formatString[$index + 1] == '$'){ - $required = true; - - ++$index; - } - - ++$index; - - $argStart = $index; - - while($index < strlen($formatString) && self::inRange(ord($formatString[$index]) - 48, 0, 9)){ - ++$index; - } - - if($argStart === $index){ + $info = self::extractPlaceholderInfo($formatString, $index); + if($info === null){ throw new \InvalidArgumentException("Invalid replacement token"); } - - $position = (int) substr($formatString, $argStart, $index); - - if($position === 0){ - throw new \InvalidArgumentException("Invalid replacement token"); - } - - --$position; - - $rest = false; - - if($index < strlen($formatString) && $formatString[$index] === "-"){ - $rest = true; - ++$index; - } - - $end = $index; + [$fullPlaceholder, $required, $position, $rest] = $info; + $position--; //array offsets start at 0, but placeholders start at 1 if($required && $position >= count($args)){ throw new \InvalidArgumentException("Missing required argument " . ($position + 1)); @@ -119,20 +98,15 @@ class FormattedCommandAlias extends Command{ $replacement = self::buildReplacement($args, $position, $rest); + $end = $index + strlen($fullPlaceholder); $formatString = substr($formatString, 0, $start) . $replacement . substr($formatString, $end); $index = $start + strlen($replacement); - - $index = strpos($formatString, '$', $index); } return $formatString; } - private static function inRange(int $i, int $j, int $k) : bool{ - return $i >= $j && $i <= $k; - } - /** * @param string[] $args * @phpstan-param list $args @@ -153,4 +127,21 @@ class FormattedCommandAlias extends Command{ return $replacement; } + + /** + * @phpstan-return array{string, bool, int, bool} + */ + private static function extractPlaceholderInfo(string $commandString, int $offset) : ?array{ + if(preg_match(self::FORMAT_STRING_REGEX, $commandString, $matches, 0, $offset) !== 1){ + return null; + } + + $fullPlaceholder = $matches[0]; + + $required = ($matches[1] ?? "") !== ""; + $position = (int) $matches[2]; + $variadic = ($matches[3] ?? "") !== ""; + + return [$fullPlaceholder, $required, $position, $variadic]; + } } From 72cfea3a630d8c20199b61d4d762eb3d64822c35 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 1 May 2022 22:05:38 +0100 Subject: [PATCH 06/32] SimpleCommandMap: extract command string parsing code into its own unit --- src/command/SimpleCommandMap.php | 14 +----- src/command/utils/CommandStringHelper.php | 60 +++++++++++++++++++++++ 2 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 src/command/utils/CommandStringHelper.php diff --git a/src/command/SimpleCommandMap.php b/src/command/SimpleCommandMap.php index 13d27c06f..1f4c45396 100644 --- a/src/command/SimpleCommandMap.php +++ b/src/command/SimpleCommandMap.php @@ -64,6 +64,7 @@ use pocketmine\command\defaults\TransferServerCommand; use pocketmine\command\defaults\VanillaCommand; use pocketmine\command\defaults\VersionCommand; use pocketmine\command\defaults\WhitelistCommand; +use pocketmine\command\utils\CommandStringHelper; use pocketmine\command\utils\InvalidCommandSyntaxException; use pocketmine\lang\KnownTranslationFactory; use pocketmine\Server; @@ -72,9 +73,7 @@ use function array_shift; use function count; use function explode; use function implode; -use function preg_match_all; use function strcasecmp; -use function stripslashes; use function strpos; use function strtolower; use function trim; @@ -197,16 +196,7 @@ class SimpleCommandMap implements CommandMap{ } public function dispatch(CommandSender $sender, string $commandLine) : bool{ - $args = []; - preg_match_all('/"((?:\\\\.|[^\\\\"])*)"|(\S+)/u', $commandLine, $matches); - foreach($matches[0] as $k => $_){ - for($i = 1; $i <= 2; ++$i){ - if($matches[$i][$k] !== ""){ - $args[$k] = $i === 1 ? stripslashes($matches[$i][$k]) : $matches[$i][$k]; - break; - } - } - } + $args = CommandStringHelper::parseQuoteAware($commandLine); $sentCommandLabel = array_shift($args); if($sentCommandLabel !== null && ($target = $this->getCommand($sentCommandLabel)) !== null){ diff --git a/src/command/utils/CommandStringHelper.php b/src/command/utils/CommandStringHelper.php new file mode 100644 index 000000000..8c675cea9 --- /dev/null +++ b/src/command/utils/CommandStringHelper.php @@ -0,0 +1,60 @@ + ['give', 'steve jobs', 'apple'] + * - `say "This is a \"string containing quotes\""` -> ['say', 'This is a "string containing quotes"'] + * + * @return string[] + * @phpstan-return list + */ + public static function parseQuoteAware(string $commandLine) : array{ + $args = []; + preg_match_all('/"((?:\\\\.|[^\\\\"])*)"|(\S+)/u', $commandLine, $matches); + foreach($matches[0] as $k => $_){ + for($i = 1; $i <= 2; ++$i){ + if($matches[$i][$k] !== ""){ + $args[(int) $k] = $i === 1 ? stripslashes($matches[$i][$k]) : $matches[$i][$k]; + break; + } + } + } + + return $args; + } +} From 91f802ac7a4fb08fe68965c83c4e8709e79b941a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 11:49:27 +0100 Subject: [PATCH 07/32] Bump phpstan/phpstan from 1.6.3 to 1.6.7 (#5015) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.6.3 to 1.6.7. - [Release notes](https://github.com/phpstan/phpstan/releases) - [Changelog](https://github.com/phpstan/phpstan/blob/1.7.x/CHANGELOG.md) - [Commits](https://github.com/phpstan/phpstan/compare/1.6.3...1.6.7) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e1389abbc..be25b6618 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.6.3", + "phpstan/phpstan": "1.6.7", "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 d04fc2d54..5e54e8914 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": "d5463f8f42873bcbbd373123eaa1f659", + "content-hash": "6a8998cdfb7158f5f7caf6d2202070ee", "packages": [ { "name": "adhocore/json-comment", @@ -1819,16 +1819,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.6.3", + "version": "1.6.7", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6128620b98292e0b69ea6d799871d77163681c8e" + "reference": "d41c39cb2e487663bce9bbd97c660e244b73abad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6128620b98292e0b69ea6d799871d77163681c8e", - "reference": "6128620b98292e0b69ea6d799871d77163681c8e", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d41c39cb2e487663bce9bbd97c660e244b73abad", + "reference": "d41c39cb2e487663bce9bbd97c660e244b73abad", "shasum": "" }, "require": { @@ -1854,7 +1854,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.6.3" + "source": "https://github.com/phpstan/phpstan/tree/1.6.7" }, "funding": [ { @@ -1874,7 +1874,7 @@ "type": "tidelift" } ], - "time": "2022-04-28T11:27:53+00:00" + "time": "2022-05-04T22:55:41+00:00" }, { "name": "phpstan/phpstan-phpunit", From 7d78b9cb2c203634582bf50178d931dc9b91cefe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 May 2022 00:55:07 +0100 Subject: [PATCH 08/32] Bump build/php from `f5d7b45` to `0b5760b` (#5023) Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `f5d7b45` to `0b5760b`. - [Release notes](https://github.com/pmmp/php-build-scripts/releases) - [Commits](https://github.com/pmmp/php-build-scripts/compare/f5d7b45990152f5b153412a78f82cfeb9c8c86b7...0b5760bb3bb96ee5546f57fbcc759568befb0d7e) --- updated-dependencies: - dependency-name: build/php dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/php b/build/php index f5d7b4599..0b5760bb3 160000 --- a/build/php +++ b/build/php @@ -1 +1 @@ -Subproject commit f5d7b45990152f5b153412a78f82cfeb9c8c86b7 +Subproject commit 0b5760bb3bb96ee5546f57fbcc759568befb0d7e From 755ca1af9b1b69226a6ed4597dc947aeec8088fe Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 00:57:50 +0100 Subject: [PATCH 09/32] Release 4.3.2 --- changelogs/4.3.md | 11 +++++++++++ src/VersionInfo.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/changelogs/4.3.md b/changelogs/4.3.md index b3e7bfbab..b5ebafe52 100644 --- a/changelogs/4.3.md +++ b/changelogs/4.3.md @@ -19,3 +19,14 @@ Released 23rd April 2022. ## Fixes - Updated BedrockProtocol dependency to fix incorrect command argument types. - Creative players no longer die in the void. + +# 4.3.2 +Released 10th May 2022. + +## Fixes +- Fixed an assertion failure in certain edge cases during world generation. +- Fixed `Entity::setNameTagVisible()` not immediately showing results to players already online. + +## Documentation +- Added more documentation in the template `pocketmine.yml` for the `aliases` config section. +- Removed useless doc comment in `PlayerChangeSkinEvent`. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 086171251..934b7ade2 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.3.2"; - public const IS_DEVELOPMENT_BUILD = true; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "stable"; private function __construct(){ From e1c4150dff1bd4ccd4919a088d950b30b1ed5874 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 00:57:50 +0100 Subject: [PATCH 10/32] 4.3.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 934b7ade2..855619bb6 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.3.2"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "4.3.3"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; private function __construct(){ From cc3c5bdb8d22ff37e7d08cf6066146bfb6c1fa5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 May 2022 12:32:22 +0100 Subject: [PATCH 11/32] Bump phpstan/phpstan from 1.6.7 to 1.6.8 (#5025) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.6.7 to 1.6.8. - [Release notes](https://github.com/phpstan/phpstan/releases) - [Changelog](https://github.com/phpstan/phpstan/blob/1.7.x/CHANGELOG.md) - [Commits](https://github.com/phpstan/phpstan/compare/1.6.7...1.6.8) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index be25b6618..a8ab49aa5 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.6.7", + "phpstan/phpstan": "1.6.8", "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 5e54e8914..2817c88ba 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": "6a8998cdfb7158f5f7caf6d2202070ee", + "content-hash": "ee1b984b67a25ec7c84aeacdc948b367", "packages": [ { "name": "adhocore/json-comment", @@ -1819,16 +1819,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.6.7", + "version": "1.6.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "d41c39cb2e487663bce9bbd97c660e244b73abad" + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d41c39cb2e487663bce9bbd97c660e244b73abad", - "reference": "d41c39cb2e487663bce9bbd97c660e244b73abad", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d76498c5531232cb8386ceb6004f7e013138d3ba", + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba", "shasum": "" }, "require": { @@ -1854,7 +1854,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.6.7" + "source": "https://github.com/phpstan/phpstan/tree/1.6.8" }, "funding": [ { @@ -1874,7 +1874,7 @@ "type": "tidelift" } ], - "time": "2022-05-04T22:55:41+00:00" + "time": "2022-05-10T06:54:21+00:00" }, { "name": "phpstan/phpstan-phpunit", From 5d64d4a1e3798b2ac803a1a034f6202fe5d049b6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 12:34:27 +0100 Subject: [PATCH 12/32] Updated phpstan-strict-rules --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 2817c88ba..c72f25538 100644 --- a/composer.lock +++ b/composer.lock @@ -1930,16 +1930,16 @@ }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.2.1", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "f3ca6464eae640a556c69a02b3b77a2507475d2f" + "reference": "0c82c96f2a55d8b91bbc7ee6512c94f68a206b43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/f3ca6464eae640a556c69a02b3b77a2507475d2f", - "reference": "f3ca6464eae640a556c69a02b3b77a2507475d2f", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/0c82c96f2a55d8b91bbc7ee6512c94f68a206b43", + "reference": "0c82c96f2a55d8b91bbc7ee6512c94f68a206b43", "shasum": "" }, "require": { @@ -1972,9 +1972,9 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.2.1" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.2.3" }, - "time": "2022-04-28T07:20:18+00:00" + "time": "2022-05-04T15:20:40+00:00" }, { "name": "phpunit/php-code-coverage", From 869d340f10eb31a6b1de016ff08ee1011bc47601 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 12:38:20 +0100 Subject: [PATCH 13/32] Regenerate PHPStan baselines --- tests/phpstan/configs/phpstan-bugs.neon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 4ade6cecd..61cb00d93 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -40,6 +40,11 @@ parameters: count: 1 path: ../../../src/network/mcpe/handler/InGamePacketHandler.php + - + message: "#^Negated boolean expression is always true\\.$#" + count: 1 + path: ../../../src/network/mcpe/handler/InGamePacketHandler.php + - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\raklib\\\\PthreadsChannelWriter\\:\\:\\$buffer is never read, only written\\.$#" count: 1 @@ -85,8 +90,3 @@ parameters: count: 2 path: ../../../src/world/format/io/region/RegionLoader.php - - - message: "#^Negated boolean expression is always true\\.$#" - count: 1 - path: ../../../src/network/mcpe/handler/InGamePacketHandler.php - From 593a4b65ea01f56e712660c20f24a846adb691c0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 13:09:26 +0100 Subject: [PATCH 14/32] World: fixed crash when using unloadChunk() during ChunkPopulateEvent, ChunkLoadEvent or when using ChunkListeners I sure hope there isn't any other cases where this edge case can appear ... closes #5022 --- src/world/World.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/world/World.php b/src/world/World.php index 9be1d06e4..49c6686ee 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -3043,9 +3043,14 @@ class World implements ChunkManager{ unset($this->activeChunkPopulationTasks[$index]); if($dirtyChunks === 0){ - $promise = $this->chunkPopulationRequestMap[$index]; - unset($this->chunkPopulationRequestMap[$index]); - $promise->resolve($chunk); + $promise = $this->chunkPopulationRequestMap[$index] ?? null; + if($promise !== null){ + unset($this->chunkPopulationRequestMap[$index]); + $promise->resolve($chunk); + }else{ + //Handlers of ChunkPopulateEvent, ChunkLoadEvent, or just ChunkListeners can cause this + $this->logger->debug("Unable to resolve population promise for chunk x=$x,z=$z - populated chunk was forcibly unloaded while setting modified chunks"); + } }else{ //request failed, stick it back on the queue //we didn't resolve the promise or touch it in any way, so any fake chunk loaders are still valid and From 69418084bc453fa704c9e828d32a8a3a7186c0aa Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 10 May 2022 15:16:04 +0300 Subject: [PATCH 15/32] Boat: fixed max stack size to match vanilla (#5018) --- src/item/Boat.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/item/Boat.php b/src/item/Boat.php index c23f69146..c117dab1d 100644 --- a/src/item/Boat.php +++ b/src/item/Boat.php @@ -42,5 +42,9 @@ class Boat extends Item{ return 1200; //400 in PC } + public function getMaxStackSize() : int{ + return 1; + } + //TODO } From 81d8aed2e23c2ace28bbfdb2ac43a8cbdc814015 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 13:58:46 +0100 Subject: [PATCH 16/32] Utils: account for named variadic arguments in printableTrace() --- src/utils/Utils.php | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index adb3187f5..a2c4e8551 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -437,6 +437,22 @@ final class Utils{ return $lines; } + private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{ + if(is_object($value)){ + return "object " . self::getNiceClassName($value) . "#" . spl_object_id($value); + } + if(is_array($value)){ + return "array[" . count($value) . "]"; + } + if(is_string($value)){ + return "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength); + } + if(is_bool($value)){ + return $value ? "true" : "false"; + } + return gettype($value) . " " . Utils::printable((string) $value); + } + /** * @param mixed[][] $trace * @phpstan-param list> $trace @@ -454,21 +470,13 @@ final class Utils{ $args = $trace[$i]["params"]; } - $params = implode(", ", array_map(function($value) use($maxStringLength) : string{ - if(is_object($value)){ - return "object " . self::getNiceClassName($value) . "#" . spl_object_id($value); - } - if(is_array($value)){ - return "array[" . count($value) . "]"; - } - if(is_string($value)){ - return "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength); - } - if(is_bool($value)){ - return $value ? "true" : "false"; - } - return gettype($value) . " " . Utils::printable((string) $value); - }, $args)); + $paramsList = []; + $offset = 0; + foreach($args as $argId => $value){ + $paramsList[] = ($argId === $offset ? "" : "$argId: ") . self::stringifyValueForTrace($value, $maxStringLength); + $offset++; + } + $params = implode(", ", $paramsList); } $messages[] = "#$i " . (isset($trace[$i]["file"]) ? Filesystem::cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" || $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")"; } From 17b0e0be84d69cc3eefef5feabf4a633b3615d9a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 14:04:52 +0100 Subject: [PATCH 17/32] Utils: use match to clean up stringifyValueForTrace() --- src/utils/Utils.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index a2c4e8551..934d51c35 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -438,19 +438,13 @@ final class Utils{ } private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{ - if(is_object($value)){ - return "object " . self::getNiceClassName($value) . "#" . spl_object_id($value); - } - if(is_array($value)){ - return "array[" . count($value) . "]"; - } - if(is_string($value)){ - return "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength); - } - if(is_bool($value)){ - return $value ? "true" : "false"; - } - return gettype($value) . " " . Utils::printable((string) $value); + return match(true){ + is_object($value) => "object " . self::getNiceClassName($value) . "#" . spl_object_id($value), + is_array($value) => "array[" . count($value) . "]", + is_string($value) => "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength), + is_bool($value) => $value ? "true" : "false", + default => gettype($value) . " " . Utils::printable((string) $value) + }; } /** From a216f4d089b01bb04094be3fa2201681553c90ba Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 14:07:07 +0100 Subject: [PATCH 18/32] Utils: improve representation of int, float and null in stack trace parameters --- src/utils/Utils.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 934d51c35..82ca8724d 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -443,6 +443,9 @@ final class Utils{ is_array($value) => "array[" . count($value) . "]", is_string($value) => "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength), is_bool($value) => $value ? "true" : "false", + is_int($value) => "int " . $value, + is_float($value) => "float " . $value, + $value === null => "null", default => gettype($value) . " " . Utils::printable((string) $value) }; } From 124edeacafee6cf61090d8205c9ec1f9f4d7e7ed Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 14:11:46 +0100 Subject: [PATCH 19/32] fix build --- src/utils/Utils.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 82ca8724d..d52e84a63 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -466,6 +466,7 @@ final class Utils{ }else{ $args = $trace[$i]["params"]; } + /** @var mixed[] $args */ $paramsList = []; $offset = 0; From a91373623537014145f33f37fc8005144625d435 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 14:13:01 +0100 Subject: [PATCH 20/32] fix CS --- src/utils/Utils.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index d52e84a63..e14745646 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -59,6 +59,7 @@ use function interface_exists; use function is_a; use function is_array; use function is_bool; +use function is_float; use function is_infinite; use function is_int; use function is_nan; From 1da6aa40f8566cd1e1a13cd93985da37f416e5da Mon Sep 17 00:00:00 2001 From: Duo Incure Date: Tue, 10 May 2022 14:17:18 +0100 Subject: [PATCH 21/32] Leaves: drop sticks with a 2% chance (#5019) as per vanilla --- src/block/Leaves.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/block/Leaves.php b/src/block/Leaves.php index 7ca55c6dc..777a29926 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -148,6 +148,9 @@ class Leaves extends Transparent{ if(($this->treeType->equals(TreeType::OAK()) || $this->treeType->equals(TreeType::DARK_OAK())) && mt_rand(1, 200) === 1){ //Apples $drops[] = VanillaItems::APPLE(); } + if(mt_rand(1, 50) === 1){ + $drops[] = VanillaItems::STICK()->setCount(mt_rand(1, 2)); + } return $drops; } From d2e421c424ea539813f09d48e73681ceafdd24fd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:09:57 +0100 Subject: [PATCH 22/32] CommandStringHelper: fixed backslashes not being removed from escaped quotes this time, without breaking eval commands ... stripslashes likes to strip ALL backslashes, whether they are actually escaping something or not, which is super annoying. --- src/command/utils/CommandStringHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/utils/CommandStringHelper.php b/src/command/utils/CommandStringHelper.php index 8c675cea9..3f24aef37 100644 --- a/src/command/utils/CommandStringHelper.php +++ b/src/command/utils/CommandStringHelper.php @@ -49,7 +49,7 @@ final class CommandStringHelper{ foreach($matches[0] as $k => $_){ for($i = 1; $i <= 2; ++$i){ if($matches[$i][$k] !== ""){ - $args[(int) $k] = $i === 1 ? stripslashes($matches[$i][$k]) : $matches[$i][$k]; + $args[(int) $k] = preg_replace('/\\\\([\\\\"])/u', '$1', $matches[$i][$k]); break; } } From eda4ae9181b8265ec001d1ae1df55863a77959e4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:11:29 +0100 Subject: [PATCH 23/32] Added unit tests for CommandStringHelper --- .../command/utils/CommandStringHelperTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/phpunit/command/utils/CommandStringHelperTest.php diff --git a/tests/phpunit/command/utils/CommandStringHelperTest.php b/tests/phpunit/command/utils/CommandStringHelperTest.php new file mode 100644 index 000000000..05381bc30 --- /dev/null +++ b/tests/phpunit/command/utils/CommandStringHelperTest.php @@ -0,0 +1,57 @@ + Date: Tue, 10 May 2022 15:21:39 +0100 Subject: [PATCH 24/32] SimpleCommandMap: parse config-defined commands according to the same rules as manually typed commands --- src/command/SimpleCommandMap.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/command/SimpleCommandMap.php b/src/command/SimpleCommandMap.php index 1f4c45396..72c896c74 100644 --- a/src/command/SimpleCommandMap.php +++ b/src/command/SimpleCommandMap.php @@ -71,7 +71,6 @@ use pocketmine\Server; use pocketmine\utils\TextFormat; use function array_shift; use function count; -use function explode; use function implode; use function strcasecmp; use function strpos; @@ -249,7 +248,7 @@ class SimpleCommandMap implements CommandMap{ $recursive = []; foreach($commandStrings as $commandString){ - $args = explode(" ", $commandString); + $args = CommandStringHelper::parseQuoteAware($commandString); $commandName = array_shift($args); $command = $this->getCommand($commandName); From 217385efb9ec507e87c6816e1e7c6fdefd9a7017 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:22:46 +0100 Subject: [PATCH 25/32] CommandStringHelper::parse() returns a non-empty list of strings --- src/command/utils/CommandStringHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/utils/CommandStringHelper.php b/src/command/utils/CommandStringHelper.php index 3f24aef37..b69577454 100644 --- a/src/command/utils/CommandStringHelper.php +++ b/src/command/utils/CommandStringHelper.php @@ -41,7 +41,7 @@ final class CommandStringHelper{ * - `say "This is a \"string containing quotes\""` -> ['say', 'This is a "string containing quotes"'] * * @return string[] - * @phpstan-return list + * @phpstan-return non-empty-list */ public static function parseQuoteAware(string $commandLine) : array{ $args = []; From a5ebbf8adbcc32fa49a0e704deb32c44fd47ba47 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:23:55 +0100 Subject: [PATCH 26/32] Fix CS again --- src/command/utils/CommandStringHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/utils/CommandStringHelper.php b/src/command/utils/CommandStringHelper.php index b69577454..dc5e00f8b 100644 --- a/src/command/utils/CommandStringHelper.php +++ b/src/command/utils/CommandStringHelper.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace pocketmine\command\utils; use function preg_match_all; -use function stripslashes; +use function preg_replace; final class CommandStringHelper{ From b875b68fc7ae41c88e70cb0234b276a54adbc108 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:24:14 +0100 Subject: [PATCH 27/32] Fix PHPStan error in CommandStringHelperTest --- tests/phpunit/command/utils/CommandStringHelperTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/command/utils/CommandStringHelperTest.php b/tests/phpunit/command/utils/CommandStringHelperTest.php index 05381bc30..d679e2057 100644 --- a/tests/phpunit/command/utils/CommandStringHelperTest.php +++ b/tests/phpunit/command/utils/CommandStringHelperTest.php @@ -48,6 +48,7 @@ class CommandStringHelperTest extends TestCase{ /** * @dataProvider parseQuoteAwareProvider + * @param string[] $expected */ public function testParseQuoteAware(string $commandLine, array $expected) : void{ $actual = CommandStringHelper::parseQuoteAware($commandLine); From 5cc0d92eff47114890a52e3c5d484531449023ec Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:38:26 +0100 Subject: [PATCH 28/32] Fixed PHPStan errors --- src/command/SimpleCommandMap.php | 2 +- src/command/utils/CommandStringHelper.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/command/SimpleCommandMap.php b/src/command/SimpleCommandMap.php index 72c896c74..548f16c39 100644 --- a/src/command/SimpleCommandMap.php +++ b/src/command/SimpleCommandMap.php @@ -249,7 +249,7 @@ class SimpleCommandMap implements CommandMap{ foreach($commandStrings as $commandString){ $args = CommandStringHelper::parseQuoteAware($commandString); - $commandName = array_shift($args); + $commandName = array_shift($args) ?? ""; $command = $this->getCommand($commandName); if($command === null){ diff --git a/src/command/utils/CommandStringHelper.php b/src/command/utils/CommandStringHelper.php index dc5e00f8b..7b24b3fdf 100644 --- a/src/command/utils/CommandStringHelper.php +++ b/src/command/utils/CommandStringHelper.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\command\utils; +use pocketmine\utils\AssumptionFailedError; use function preg_match_all; use function preg_replace; @@ -41,7 +42,7 @@ final class CommandStringHelper{ * - `say "This is a \"string containing quotes\""` -> ['say', 'This is a "string containing quotes"'] * * @return string[] - * @phpstan-return non-empty-list + * @phpstan-return list */ public static function parseQuoteAware(string $commandLine) : array{ $args = []; @@ -49,7 +50,9 @@ final class CommandStringHelper{ foreach($matches[0] as $k => $_){ for($i = 1; $i <= 2; ++$i){ if($matches[$i][$k] !== ""){ - $args[(int) $k] = preg_replace('/\\\\([\\\\"])/u', '$1', $matches[$i][$k]); + /** @var string $match */ //phpstan can't understand preg_match and friends by itself :( + $match = $matches[$i][$k]; + $args[(int) $k] = preg_replace('/\\\\([\\\\"])/u', '$1', $match) ?? throw new AssumptionFailedError(preg_last_error_msg()); break; } } From 4c29f982929049c968e6ebf87e1050478709bec3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 15:39:44 +0100 Subject: [PATCH 29/32] "Fix CS" are going to be my final words ... --- src/command/utils/CommandStringHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/command/utils/CommandStringHelper.php b/src/command/utils/CommandStringHelper.php index 7b24b3fdf..526f2d594 100644 --- a/src/command/utils/CommandStringHelper.php +++ b/src/command/utils/CommandStringHelper.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\command\utils; use pocketmine\utils\AssumptionFailedError; +use function preg_last_error_msg; use function preg_match_all; use function preg_replace; From 3e1246acff0570088cc09c856570ffc0fb179de4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 May 2022 16:03:09 +0100 Subject: [PATCH 30/32] FormattedCommandAlias: Invoke commands directly with pre-parsed arguments this resolves a range of issues with quoted arguments when using placeholders, as well as improving performance (no redundant combine -> re-parse needed). --- src/command/FormattedCommandAlias.php | 47 ++++++++++++++++++---- tests/phpstan/configs/actual-problems.neon | 10 +++++ 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/command/FormattedCommandAlias.php b/src/command/FormattedCommandAlias.php index 13281a8eb..d710dd971 100644 --- a/src/command/FormattedCommandAlias.php +++ b/src/command/FormattedCommandAlias.php @@ -23,8 +23,13 @@ declare(strict_types=1); namespace pocketmine\command; -use pocketmine\Server; +use pocketmine\command\utils\CommandStringHelper; +use pocketmine\command\utils\InvalidCommandSyntaxException; +use pocketmine\lang\KnownTranslationFactory; +use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\TextFormat; +use function array_map; +use function array_shift; use function count; use function preg_match; use function strlen; @@ -52,24 +57,52 @@ class FormattedCommandAlias extends Command{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ - $commands = []; - $result = false; + $result = true; foreach($this->formatStrings as $formatString){ try{ - $commands[] = $this->buildCommand($formatString, $args); + $formatArgs = CommandStringHelper::parseQuoteAware($formatString); + $commands[] = array_map(fn(string $formatArg) => $this->buildCommand($formatArg, $args), $formatArgs); }catch(\InvalidArgumentException $e){ $sender->sendMessage(TextFormat::RED . $e->getMessage()); return false; } } - foreach($commands as $command){ - $result |= Server::getInstance()->dispatchCommand($sender, $command, true); + $commandMap = $sender->getServer()->getCommandMap(); + foreach($commands as $commandArgs){ + //this approximately duplicates the logic found in SimpleCommandMap::dispatch() + //this is to allow directly invoking the commands without having to rebuild a command string and parse it + //again for no reason + //TODO: a method on CommandMap to invoke a command with pre-parsed arguments would probably be a good idea + //for a future major version + $commandLabel = array_shift($commandArgs); + if($commandLabel === null){ + throw new AssumptionFailedError("This should have been checked before construction"); + } + + if(($target = $commandMap->getCommand($commandLabel)) !== null){ + $target->timings->startTiming(); + + try{ + $target->execute($sender, $commandLabel, $args); + }catch(InvalidCommandSyntaxException $e){ + $sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage()))); + }finally{ + $target->timings->stopTiming(); + } + }else{ + $sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::pocketmine_command_notFound($commandLabel, "/help")->prefix(TextFormat::RED))); + + //to match the behaviour of SimpleCommandMap::dispatch() + //this shouldn't normally happen, but might happen if the command was unregistered or modified after + //the alias was installed + $result = false; + } } - return (bool) $result; + return $result; } /** diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index d3776de3d..67fa6bd2e 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -440,6 +440,16 @@ parameters: count: 1 path: ../../../src/command/Command.php + - + message: "#^Cannot call method startTiming\\(\\) on pocketmine\\\\timings\\\\TimingsHandler\\|null\\.$#" + count: 1 + path: ../../../src/command/FormattedCommandAlias.php + + - + message: "#^Cannot call method stopTiming\\(\\) on pocketmine\\\\timings\\\\TimingsHandler\\|null\\.$#" + count: 1 + path: ../../../src/command/FormattedCommandAlias.php + - message: "#^Cannot call method startTiming\\(\\) on pocketmine\\\\timings\\\\TimingsHandler\\|null\\.$#" count: 1 From 77530b0c24a0fb2716ad810293c260538ae45c0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 May 2022 12:55:36 +0100 Subject: [PATCH 31/32] Bump build/php from `0b5760b` to `19222cf` (#5027) Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `0b5760b` to `19222cf`. - [Release notes](https://github.com/pmmp/php-build-scripts/releases) - [Commits](https://github.com/pmmp/php-build-scripts/compare/0b5760bb3bb96ee5546f57fbcc759568befb0d7e...19222cfb2867869cfc9b96fbc5f6cdbd601f5e8b) --- updated-dependencies: - dependency-name: build/php dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/php b/build/php index 0b5760bb3..19222cfb2 160000 --- a/build/php +++ b/build/php @@ -1 +1 @@ -Subproject commit 0b5760bb3bb96ee5546f57fbcc759568befb0d7e +Subproject commit 19222cfb2867869cfc9b96fbc5f6cdbd601f5e8b From 212c94ce98f9d20415e6f55aa64705f4ea7253d7 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 May 2022 13:07:45 +0100 Subject: [PATCH 32/32] PluginManager: Log an error message when a plugin disables itself during enabling --- composer.json | 2 +- composer.lock | 14 +++++++------- src/lang/KnownTranslationFactory.php | 11 +++++++++++ src/lang/KnownTranslationKeys.php | 2 ++ src/plugin/PluginManager.php | 7 +++++++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 1f747eabf..4079ecd1e 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "pocketmine/classloader": "^0.2.0", "pocketmine/color": "^0.2.0", "pocketmine/errorhandler": "^0.6.0", - "pocketmine/locale-data": "~2.6.0", + "pocketmine/locale-data": "~2.7.0", "pocketmine/log": "^0.4.0", "pocketmine/log-pthreads": "^0.4.0", "pocketmine/math": "^0.4.0", diff --git a/composer.lock b/composer.lock index 6f4d1f27d..0638ac6a0 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": "1987b70747167a4b099962f485f46bf4", + "content-hash": "c36ed8a47610c2fc26dfab18085c431c", "packages": [ { "name": "adhocore/json-comment", @@ -536,16 +536,16 @@ }, { "name": "pocketmine/locale-data", - "version": "2.6.2", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/pmmp/Language.git", - "reference": "eae9303493884edcc5321b50002a5dc956a36a23" + "reference": "f00216c4709d2c5a2af478498315206b336b8e2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Language/zipball/eae9303493884edcc5321b50002a5dc956a36a23", - "reference": "eae9303493884edcc5321b50002a5dc956a36a23", + "url": "https://api.github.com/repos/pmmp/Language/zipball/f00216c4709d2c5a2af478498315206b336b8e2e", + "reference": "f00216c4709d2c5a2af478498315206b336b8e2e", "shasum": "" }, "type": "library", @@ -553,9 +553,9 @@ "description": "Language resources used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/Language/issues", - "source": "https://github.com/pmmp/Language/tree/2.6.2" + "source": "https://github.com/pmmp/Language/tree/2.7.0" }, - "time": "2022-04-10T20:44:40+00:00" + "time": "2022-05-10T13:29:27+00:00" }, { "name": "pocketmine/log", diff --git a/src/lang/KnownTranslationFactory.php b/src/lang/KnownTranslationFactory.php index 7bff33d9b..6458215ba 100644 --- a/src/lang/KnownTranslationFactory.php +++ b/src/lang/KnownTranslationFactory.php @@ -1759,6 +1759,13 @@ final class KnownTranslationFactory{ ]); } + public static function pocketmine_plugin_enableError(Translatable|string $param0, Translatable|string $param1) : Translatable{ + return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_ENABLEERROR, [ + 0 => $param0, + 1 => $param1, + ]); + } + public static function pocketmine_plugin_extensionNotLoaded(Translatable|string $extensionName) : Translatable{ return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_EXTENSIONNOTLOADED, [ "extensionName" => $extensionName, @@ -1859,6 +1866,10 @@ final class KnownTranslationFactory{ ]); } + public static function pocketmine_plugin_suicide() : Translatable{ + return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_SUICIDE, []); + } + public static function pocketmine_plugin_unknownDependency(Translatable|string $param0) : Translatable{ return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_UNKNOWNDEPENDENCY, [ 0 => $param0, diff --git a/src/lang/KnownTranslationKeys.php b/src/lang/KnownTranslationKeys.php index ff3c448fe..9201f4b6f 100644 --- a/src/lang/KnownTranslationKeys.php +++ b/src/lang/KnownTranslationKeys.php @@ -368,6 +368,7 @@ final class KnownTranslationKeys{ public const POCKETMINE_PLUGIN_DUPLICATEPERMISSIONERROR = "pocketmine.plugin.duplicatePermissionError"; public const POCKETMINE_PLUGIN_EMPTYEXTENSIONVERSIONCONSTRAINT = "pocketmine.plugin.emptyExtensionVersionConstraint"; public const POCKETMINE_PLUGIN_ENABLE = "pocketmine.plugin.enable"; + public const POCKETMINE_PLUGIN_ENABLEERROR = "pocketmine.plugin.enableError"; public const POCKETMINE_PLUGIN_EXTENSIONNOTLOADED = "pocketmine.plugin.extensionNotLoaded"; public const POCKETMINE_PLUGIN_GENERICLOADERROR = "pocketmine.plugin.genericLoadError"; public const POCKETMINE_PLUGIN_INCOMPATIBLEAPI = "pocketmine.plugin.incompatibleAPI"; @@ -385,6 +386,7 @@ final class KnownTranslationKeys{ public const POCKETMINE_PLUGIN_MAINCLASSWRONGTYPE = "pocketmine.plugin.mainClassWrongType"; public const POCKETMINE_PLUGIN_RESTRICTEDNAME = "pocketmine.plugin.restrictedName"; public const POCKETMINE_PLUGIN_SPACESDISCOURAGED = "pocketmine.plugin.spacesDiscouraged"; + public const POCKETMINE_PLUGIN_SUICIDE = "pocketmine.plugin.suicide"; public const POCKETMINE_PLUGIN_UNKNOWNDEPENDENCY = "pocketmine.plugin.unknownDependency"; public const POCKETMINE_SAVE_START = "pocketmine.save.start"; public const POCKETMINE_SAVE_SUCCESS = "pocketmine.save.success"; diff --git a/src/plugin/PluginManager.php b/src/plugin/PluginManager.php index 5cb4e4637..47f3a257b 100644 --- a/src/plugin/PluginManager.php +++ b/src/plugin/PluginManager.php @@ -447,6 +447,13 @@ class PluginManager{ $this->enabledPlugins[$plugin->getDescription()->getName()] = $plugin; (new PluginEnableEvent($plugin))->call(); + }else{ + $this->server->getLogger()->critical($this->server->getLanguage()->translate( + KnownTranslationFactory::pocketmine_plugin_enableError( + $plugin->getName(), + KnownTranslationFactory::pocketmine_plugin_suicide() + ) + )); } } }