Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2021-12-14 00:34:54 +00:00
commit 8a94aa10a4
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
10 changed files with 68 additions and 22 deletions

View File

@ -10,7 +10,7 @@
<a href="https://discord.gg/bmSAZBG"><img src="https://img.shields.io/discord/373199722573201408?label=discord&color=7289DA&logo=discord" alt="Discord" /></a>
<br>
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/pmmp/PocketMine-MP/total?label=downloads%40total">
<img alt="GitHub release (latest by SemVer)" src="https://img.shields.io/github/downloads/pmmp/PocketMine-MP/latest/total">
<img alt="GitHub release (latest by SemVer)" src="https://img.shields.io/github/downloads/pmmp/PocketMine-MP/latest/total?sort=semver">
</p>
## Getting started

View File

@ -41,6 +41,7 @@ use function preg_match_all;
use function str_replace;
use function strtoupper;
use const INI_SCANNER_RAW;
use const SORT_NUMERIC;
use const SORT_STRING;
use const STDERR;
@ -95,6 +96,8 @@ function generate_known_translation_keys(array $languageDefinitions) : void{
/**
* This class contains constants for all the translations known to PocketMine-MP as per the used version of pmmp/Language.
* This class is generated automatically, do NOT modify it by hand.
*
* @internal
*/
final class KnownTranslationKeys{
@ -127,6 +130,8 @@ function generate_known_translation_factory(array $languageDefinitions) : void{
* This class contains factory methods for all the translations known to PocketMine-MP as per the used version of
* pmmp/Language.
* This class is generated automatically, do NOT modify it by hand.
*
* @internal
*/
final class KnownTranslationFactory{
@ -138,15 +143,20 @@ HEADER;
$translationContainerClass = (new \ReflectionClass(Translatable::class))->getShortName();
foreach(Utils::stringifyKeys($languageDefinitions) as $key => $value){
$parameters = [];
$allParametersPositional = true;
if(preg_match_all($parameterRegex, $value, $matches) > 0){
foreach($matches[1] as $parameterName){
if(is_numeric($parameterName)){
$parameters[$parameterName] = "param$parameterName";
}else{
$parameters[$parameterName] = $parameterName;
$allParametersPositional = false;
}
}
}
if($allParametersPositional){
ksort($parameters, SORT_NUMERIC);
}
echo "\tpublic static function " .
functionify($key) .
"(" . implode(", ", array_map(fn(string $paramName) => "$translationContainerClass|string \$$paramName", $parameters)) . ") : $translationContainerClass{\n";

View File

@ -1547,3 +1547,21 @@ Released 9th December 2021.
- `Config->save()` will no longer write empty data to the file when using JSON and the data fails to encode - an exception will be thrown instead.
- `StringToItemParser` now returns the correct items for `bamboo`, `shulker_box`, `stone_slab`, `stone_stairs` and `tall_grass`.
- `StringToItemParser` now recognizes `slime` and `slime_block` (these were previously missing).
# 4.0.2
Released 12th December 2021.
## Fixes
### Core
- Fixed server crash when loading written books containing pages with invalid UTF-8 characters - the invalid characters are now scrubbed.
- Fixed server crash when root type of `plugin.yml` is valid, but not an array.
- Fixed ConsoleReader crash due OPcache ASLR issue - it's not clear what caused this, but OPcache is not needed in the subprocess anyway.
- Fixed backslashes getting stripped from unquoted command arguments - these were only supposed to be stripped from quoted arguments, to allow escaping of quotes.
- `build/generate-known-translation-apis.php` now sorts numerically-indexed arguments into ascending order, irrespective of the order they appear in the original string.
### API
- `KnownTranslationKeys` and `KnownTranslationFactory` are now marked `@internal`.
- `ItemEntity` now clones the itemstack passed to its constructor, fixing various confusing mutability issues.
- `PlayerExperienceChangeEvent->setNewProgress()` now performs range checks. This fixes the root of a very old and confusing crash bug which took several years to identify the cause of.
- Note that the defective plugin(s) which caused this problem will still cause a server crash, but the plugin responsible will now get blamed correctly.
- `GeneratorManager->addGenerator()` now consistently converts the given alias to lowercase. Due to a bug, it previously didn't do this if the `$overwrite` parameter was set to `true`, causing a range of confusing bugs.

View File

@ -41,7 +41,7 @@
"pocketmine/classloader": "^0.2.0",
"pocketmine/color": "^0.2.0",
"pocketmine/errorhandler": "^0.3.0",
"pocketmine/locale-data": "^2.0.16",
"pocketmine/locale-data": "^2.1.0",
"pocketmine/log": "^0.4.0",
"pocketmine/log-pthreads": "^0.4.0",
"pocketmine/math": "^0.4.0",

32
composer.lock generated
View File

@ -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": "b515e7eebbf12a6251d2df817ce56dbc",
"content-hash": "6a1fde030a0133e4ff23047afab5727e",
"packages": [
{
"name": "adhocore/json-comment",
@ -123,24 +123,24 @@
},
{
"name": "fgrosse/phpasn1",
"version": "v2.3.0",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/fgrosse/PHPASN1.git",
"reference": "20299033c35f4300eb656e7e8e88cf52d1d6694e"
"reference": "eef488991d53e58e60c9554b09b1201ca5ba9296"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/20299033c35f4300eb656e7e8e88cf52d1d6694e",
"reference": "20299033c35f4300eb656e7e8e88cf52d1d6694e",
"url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/eef488991d53e58e60c9554b09b1201ca5ba9296",
"reference": "eef488991d53e58e60c9554b09b1201ca5ba9296",
"shasum": ""
},
"require": {
"php": ">=7.0.0"
"php": "~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0"
},
"require-dev": {
"phpunit/phpunit": "~6.3",
"satooshi/php-coveralls": "~2.0"
"php-coveralls/php-coveralls": "~2.0",
"phpunit/phpunit": "^6.3 || ^7.0 || ^8.0"
},
"suggest": {
"ext-bcmath": "BCmath is the fallback extension for big integer calculations",
@ -192,9 +192,9 @@
],
"support": {
"issues": "https://github.com/fgrosse/PHPASN1/issues",
"source": "https://github.com/fgrosse/PHPASN1/tree/v2.3.0"
"source": "https://github.com/fgrosse/PHPASN1/tree/v2.4.0"
},
"time": "2021-04-24T19:01:55+00:00"
"time": "2021-12-11T12:41:06+00:00"
},
{
"name": "netresearch/jsonmapper",
@ -535,16 +535,16 @@
},
{
"name": "pocketmine/locale-data",
"version": "2.0.22",
"version": "2.1.25",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Language.git",
"reference": "181eb9d42653296e65d55a1bbba10e0dd76bbd61"
"reference": "0c810aaa24baffcccd57ca5bca16ca8f346c483c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Language/zipball/181eb9d42653296e65d55a1bbba10e0dd76bbd61",
"reference": "181eb9d42653296e65d55a1bbba10e0dd76bbd61",
"url": "https://api.github.com/repos/pmmp/Language/zipball/0c810aaa24baffcccd57ca5bca16ca8f346c483c",
"reference": "0c810aaa24baffcccd57ca5bca16ca8f346c483c",
"shasum": ""
},
"type": "library",
@ -552,9 +552,9 @@
"description": "Language resources used by PocketMine-MP",
"support": {
"issues": "https://github.com/pmmp/Language/issues",
"source": "https://github.com/pmmp/Language/tree/2.0.22"
"source": "https://github.com/pmmp/Language/tree/2.1.25"
},
"time": "2021-12-04T22:37:10+00:00"
"time": "2021-12-14T00:29:11+00:00"
},
{
"name": "pocketmine/log",

View File

@ -324,6 +324,9 @@ class MemoryManager{
if(!$property->isPublic()){
$property->setAccessible(true);
}
if(!$property->isInitialized()){
continue;
}
$staticCount++;
$staticProperties[$className][$property->getName()] = self::continueDump($property->getValue(), $objects, $refCounts, 0, $maxNesting, $maxStringSize);
@ -447,6 +450,9 @@ class MemoryManager{
if(!$property->isPublic()){
$property->setAccessible(true);
}
if(!$property->isInitialized($object)){
continue;
}
$info["properties"][$name] = self::continueDump($property->getValue($object), $objects, $refCounts, 0, $maxNesting, $maxStringSize);
}

View File

@ -87,7 +87,7 @@ final class ConsoleReaderThread extends Thread{
//Windows sucks, and likes to corrupt UTF-8 file paths when they travel to the subprocess, so we base64 encode
//the path to avoid the problem. This is an abysmally shitty hack, but here we are :(
$sub = Utils::assumeNotFalse(proc_open(
[PHP_BINARY, '-r', sprintf('require base64_decode("%s", true);', base64_encode(Path::join(__DIR__, 'ConsoleReaderChildProcess.php'))), $address],
[PHP_BINARY, '-dopcache.enable_cli=0', '-r', sprintf('require base64_decode("%s", true);', base64_encode(Path::join(__DIR__, 'ConsoleReaderChildProcess.php'))), $address],
[
2 => fopen("php://stderr", "w"),
],

View File

@ -27,6 +27,8 @@ namespace pocketmine\lang;
* This class contains factory methods for all the translations known to PocketMine-MP as per the used version of
* pmmp/Language.
* This class is generated automatically, do NOT modify it by hand.
*
* @internal
*/
final class KnownTranslationFactory{
public static function ability_flight() : Translatable{
@ -242,10 +244,10 @@ final class KnownTranslationFactory{
return new Translatable(KnownTranslationKeys::COMMANDS_ENCHANT_USAGE, []);
}
public static function commands_gamemode_success_other(Translatable|string $param1, Translatable|string $param0) : Translatable{
public static function commands_gamemode_success_other(Translatable|string $param0, Translatable|string $param1) : Translatable{
return new Translatable(KnownTranslationKeys::COMMANDS_GAMEMODE_SUCCESS_OTHER, [
1 => $param1,
0 => $param0,
1 => $param1,
]);
}
@ -915,6 +917,12 @@ final class KnownTranslationFactory{
return new Translatable(KnownTranslationKeys::GAMEMODE_INFO, []);
}
public static function gamemode_options(Translatable|string $param0) : Translatable{
return new Translatable(KnownTranslationKeys::GAMEMODE_OPTIONS, [
0 => $param0,
]);
}
public static function invalid_port() : Translatable{
return new Translatable(KnownTranslationKeys::INVALID_PORT, []);
}

View File

@ -26,6 +26,8 @@ namespace pocketmine\lang;
/**
* This class contains constants for all the translations known to PocketMine-MP as per the used version of pmmp/Language.
* This class is generated automatically, do NOT modify it by hand.
*
* @internal
*/
final class KnownTranslationKeys{
public const ABILITY_FLIGHT = "ability.flight";
@ -201,6 +203,7 @@ final class KnownTranslationKeys{
public const GAMEMODE_SPECTATOR = "gameMode.spectator";
public const GAMEMODE_SURVIVAL = "gameMode.survival";
public const GAMEMODE_INFO = "gamemode_info";
public const GAMEMODE_OPTIONS = "gamemode_options";
public const INVALID_PORT = "invalid_port";
public const IP_CONFIRM = "ip_confirm";
public const IP_GET = "ip_get";

View File

@ -72,7 +72,8 @@ final class GeneratorManager{
public function addGenerator(string $class, string $name, \Closure $presetValidator, bool $overwrite = false) : void{
Utils::testValidInstance($class, Generator::class);
if(!$overwrite and isset($this->list[$name = strtolower($name)])){
$name = strtolower($name);
if(!$overwrite and isset($this->list[$name])){
throw new \InvalidArgumentException("Alias \"$name\" is already assigned");
}