Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor 2021-11-08 19:53:56 +00:00
commit eb9012401b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 16 additions and 9 deletions

View File

@ -53,7 +53,7 @@
"webmozart/path-util": "^2.3"
},
"require-dev": {
"phpstan/phpstan": "1.0.2",
"phpstan/phpstan": "1.1.1",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.2"

14
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": "6de5c66b7a0f693fd30c701b0d0db3d1",
"content-hash": "4f8e023ae390414fb40b77857c16ebee",
"packages": [
{
"name": "adhocore/json-comment",
@ -1898,16 +1898,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.0.2",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91"
"reference": "cb317029197236c571c1b9305b8dd12850d8d85c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e9e2a501102ba0b126b2f63a7f0a3b151056fe91",
"reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/cb317029197236c571c1b9305b8dd12850d8d85c",
"reference": "cb317029197236c571c1b9305b8dd12850d8d85c",
"shasum": ""
},
"require": {
@ -1938,7 +1938,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.0.2"
"source": "https://github.com/phpstan/phpstan/tree/1.1.1"
},
"funding": [
{
@ -1958,7 +1958,7 @@
"type": "tidelift"
}
],
"time": "2021-11-03T16:09:51+00:00"
"time": "2021-11-06T22:46:47+00:00"
},
{
"name": "phpstan/phpstan-phpunit",

View File

@ -27,6 +27,7 @@ use pocketmine\entity\utils\ExperienceUtils;
use pocketmine\event\player\PlayerExperienceChangeEvent;
use pocketmine\item\Durable;
use pocketmine\item\enchantment\VanillaEnchantments;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Limits;
use pocketmine\world\sound\XpCollectSound;
use pocketmine\world\sound\XpLevelUpSound;
@ -35,6 +36,7 @@ use function ceil;
use function count;
use function max;
use function min;
use function sprintf;
class ExperienceManager{
@ -142,7 +144,12 @@ class ExperienceManager{
public function setCurrentTotalXp(int $amount) : bool{
$newLevel = ExperienceUtils::getLevelFromXp($amount);
return $this->setXpAndProgress((int) $newLevel, $newLevel - ((int) $newLevel));
$xpLevel = (int) $newLevel;
$xpProgress = $newLevel - (int) $newLevel;
if($xpProgress > 1.0){
throw new AssumptionFailedError(sprintf("newLevel - (int) newLevel should never be bigger than 1, but have %.53f (newLevel=%.53f)", $xpProgress, $newLevel));
}
return $this->setXpAndProgress($xpLevel, $xpProgress);
}
/**