Merge branch 'stable' into master

# Conflicts:
#	build/make-release.php
#	composer.lock
#	resources/vanilla
#	src/plugin/PluginDescription.php
#	src/pocketmine/entity/Human.php
This commit is contained in:
Dylan K. Taylor 2020-10-21 16:55:52 +01:00
commit 23e5ade77e
6 changed files with 37 additions and 23 deletions

View File

@ -51,7 +51,7 @@
"respect/validation": "^2.0"
},
"require-dev": {
"phpstan/phpstan": "0.12.49",
"phpstan/phpstan": "0.12.50",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "^9.2"

36
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": "cfc91763774445e65e366642b2efdde1",
"content-hash": "e95b28ee9d9e452e1506f3fef18d42af",
"packages": [
{
"name": "adhocore/json-comment",
@ -52,16 +52,16 @@
},
{
"name": "fgrosse/phpasn1",
"version": "v2.1.1",
"version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/fgrosse/PHPASN1.git",
"reference": "7ebf2a09084a7bbdb7b879c66fdf7ad80461bbe8"
"reference": "d1978f7abd580f3fc33561e7f71d4c12c7531fad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/7ebf2a09084a7bbdb7b879c66fdf7ad80461bbe8",
"reference": "7ebf2a09084a7bbdb7b879c66fdf7ad80461bbe8",
"url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/d1978f7abd580f3fc33561e7f71d4c12c7531fad",
"reference": "d1978f7abd580f3fc33561e7f71d4c12c7531fad",
"shasum": ""
},
"require": {
@ -72,8 +72,10 @@
"satooshi/php-coveralls": "~2.0"
},
"suggest": {
"ext-bcmath": "BCmath is the fallback extension for big integer calculations",
"ext-curl": "For loading OID information from the web if they have not bee defined statically",
"ext-gmp": "GMP is the preferred extension for big integer calculations",
"php-curl": "For loading OID information from the web if they have not bee defined statically"
"phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available"
},
"type": "library",
"extra": {
@ -117,7 +119,7 @@
"x509",
"x690"
],
"time": "2018-12-02T01:34:34+00:00"
"time": "2020-10-11T16:28:18+00:00"
},
{
"name": "mdanter/ecc",
@ -1444,16 +1446,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.49",
"version": "0.12.50",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "9a6136c2b39d5214da78de37128d5fe08e5d5b05"
"reference": "b8248f9c81265af75d6d969ca3252aaf3e998f3a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9a6136c2b39d5214da78de37128d5fe08e5d5b05",
"reference": "9a6136c2b39d5214da78de37128d5fe08e5d5b05",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b8248f9c81265af75d6d969ca3252aaf3e998f3a",
"reference": "b8248f9c81265af75d6d969ca3252aaf3e998f3a",
"shasum": ""
},
"require": {
@ -1496,7 +1498,7 @@
"type": "tidelift"
}
],
"time": "2020-10-12T14:10:44+00:00"
"time": "2020-10-16T12:22:23+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
@ -1905,16 +1907,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.4.1",
"version": "9.4.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "1f09a12726593737e8a228ebb1c8647305d07c41"
"reference": "3866b2eeeed21b1b099c4bc0b7a1690ac6fd5baa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1f09a12726593737e8a228ebb1c8647305d07c41",
"reference": "1f09a12726593737e8a228ebb1c8647305d07c41",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3866b2eeeed21b1b099c4bc0b7a1690ac6fd5baa",
"reference": "3866b2eeeed21b1b099c4bc0b7a1690ac6fd5baa",
"shasum": ""
},
"require": {
@ -2000,7 +2002,7 @@
"type": "github"
}
],
"time": "2020-10-11T07:41:19+00:00"
"time": "2020-10-19T09:23:29+00:00"
},
{
"name": "sebastian/cli-parser",

View File

@ -151,12 +151,13 @@ class ExperienceManager{
* @param bool $playSound Whether to play level-up and XP gained sounds.
*/
public function addXp(int $amount, bool $playSound = true) : bool{
$this->totalXp += $amount;
$oldLevel = $this->getXpLevel();
$oldTotal = $this->getCurrentTotalXp();
if($this->setCurrentTotalXp($oldTotal + $amount)){
if($amount > 0){
$this->totalXp += $amount;
}
if($playSound){
$newLevel = $this->getXpLevel();
if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){

View File

@ -25,6 +25,7 @@ namespace pocketmine\entity\utils;
use pocketmine\math\Math;
use pocketmine\utils\AssumptionFailedError;
use function count;
use function max;
abstract class ExperienceUtils{

View File

@ -102,13 +102,13 @@ class PluginDescription{
$this->name = $plugin["name"];
if(preg_match('/^[A-Za-z0-9 _.-]+$/', $this->name) === 0){
throw new PluginException("Invalid PluginDescription name");
throw new PluginException("Invalid Plugin name");
}
$this->name = str_replace(" ", "_", $this->name);
$this->version = (string) $plugin["version"];
$this->main = $plugin["main"];
if(stripos($this->main, "pocketmine\\") === 0){
throw new PluginException("Invalid PluginDescription main, cannot start within the PocketMine namespace");
throw new PluginException("Invalid Plugin main, cannot start within the PocketMine namespace");
}
$this->api = array_map("\strval", (array) ($plugin["api"] ?? []));
@ -148,7 +148,7 @@ class PluginDescription{
try{
$this->order = PluginLoadOrder::fromString($plugin["load"]);
}catch(\InvalidArgumentException $e){
throw new PluginException("Invalid PluginDescription \"load\"");
throw new PluginException("Invalid Plugin \"load\"");
}
}else{
$this->order = PluginLoadOrder::POSTWORLD();

View File

@ -262,6 +262,16 @@ class AsyncPool{
return $more;
}
/**
* Returns an array of worker ID => task queue size
*
* @return int[]
* @phpstan-return array<int, int>
*/
public function getTaskQueueSizes() : array{
return $this->workerUsage;
}
public function shutdownUnusedWorkers() : int{
$ret = 0;
$time = time();