diff --git a/build/php b/build/php index 7b357f8cf..19222cfb2 160000 --- a/build/php +++ b/build/php @@ -1 +1 @@ -Subproject commit 7b357f8cf9b2d2ee3a9ad247cdc76c8ad62337f9 +Subproject commit 19222cfb2867869cfc9b96fbc5f6cdbd601f5e8b 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/composer.json b/composer.json index 4079ecd1e..0aa6ec91e 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.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 0638ac6a0..b3a1fab4d 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": "c36ed8a47610c2fc26dfab18085c431c", + "content-hash": "d6e210ffd1d4dbe1ed2c18f7c4abf385", "packages": [ { "name": "adhocore/json-comment", @@ -1819,16 +1819,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.6.3", + "version": "1.6.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6128620b98292e0b69ea6d799871d77163681c8e" + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6128620b98292e0b69ea6d799871d77163681c8e", - "reference": "6128620b98292e0b69ea6d799871d77163681c8e", + "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.3" + "source": "https://github.com/phpstan/phpstan/tree/1.6.8" }, "funding": [ { @@ -1874,7 +1874,7 @@ "type": "tidelift" } ], - "time": "2022-04-28T11:27:53+00:00" + "time": "2022-05-10T06:54:21+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -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", 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] 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{ 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 } diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 4654b7c87..94ed1d97e 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; @@ -435,6 +436,19 @@ final class Utils{ return $lines; } + private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{ + 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", + is_int($value) => "int " . $value, + is_float($value) => "float " . $value, + $value === null => "null", + default => gettype($value) . " " . Utils::printable((string) $value) + }; + } + /** * @param mixed[][] $trace * @phpstan-param list> $trace @@ -451,22 +465,15 @@ final class Utils{ }else{ $args = $trace[$i]["params"]; } + /** @var mixed[] $args */ - $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) . ")"; } diff --git a/src/world/World.php b/src/world/World.php index f57c50d38..687014c1e 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -3004,9 +3004,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 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 -