mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +00:00
Merge branch 'stable'
This commit is contained in:
commit
eb9012401b
@ -53,7 +53,7 @@
|
|||||||
"webmozart/path-util": "^2.3"
|
"webmozart/path-util": "^2.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpstan/phpstan": "1.0.2",
|
"phpstan/phpstan": "1.1.1",
|
||||||
"phpstan/phpstan-phpunit": "^1.0.0",
|
"phpstan/phpstan-phpunit": "^1.0.0",
|
||||||
"phpstan/phpstan-strict-rules": "^1.0.0",
|
"phpstan/phpstan-strict-rules": "^1.0.0",
|
||||||
"phpunit/phpunit": "^9.2"
|
"phpunit/phpunit": "^9.2"
|
||||||
|
14
composer.lock
generated
14
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "6de5c66b7a0f693fd30c701b0d0db3d1",
|
"content-hash": "4f8e023ae390414fb40b77857c16ebee",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adhocore/json-comment",
|
"name": "adhocore/json-comment",
|
||||||
@ -1898,16 +1898,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan",
|
"name": "phpstan/phpstan",
|
||||||
"version": "1.0.2",
|
"version": "1.1.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpstan.git",
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
"reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91"
|
"reference": "cb317029197236c571c1b9305b8dd12850d8d85c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e9e2a501102ba0b126b2f63a7f0a3b151056fe91",
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/cb317029197236c571c1b9305b8dd12850d8d85c",
|
||||||
"reference": "e9e2a501102ba0b126b2f63a7f0a3b151056fe91",
|
"reference": "cb317029197236c571c1b9305b8dd12850d8d85c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1938,7 +1938,7 @@
|
|||||||
"description": "PHPStan - PHP Static Analysis Tool",
|
"description": "PHPStan - PHP Static Analysis Tool",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpstan/phpstan/issues",
|
"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": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1958,7 +1958,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-11-03T16:09:51+00:00"
|
"time": "2021-11-06T22:46:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan-phpunit",
|
"name": "phpstan/phpstan-phpunit",
|
||||||
|
@ -27,6 +27,7 @@ use pocketmine\entity\utils\ExperienceUtils;
|
|||||||
use pocketmine\event\player\PlayerExperienceChangeEvent;
|
use pocketmine\event\player\PlayerExperienceChangeEvent;
|
||||||
use pocketmine\item\Durable;
|
use pocketmine\item\Durable;
|
||||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||||
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
use pocketmine\utils\Limits;
|
use pocketmine\utils\Limits;
|
||||||
use pocketmine\world\sound\XpCollectSound;
|
use pocketmine\world\sound\XpCollectSound;
|
||||||
use pocketmine\world\sound\XpLevelUpSound;
|
use pocketmine\world\sound\XpLevelUpSound;
|
||||||
@ -35,6 +36,7 @@ use function ceil;
|
|||||||
use function count;
|
use function count;
|
||||||
use function max;
|
use function max;
|
||||||
use function min;
|
use function min;
|
||||||
|
use function sprintf;
|
||||||
|
|
||||||
class ExperienceManager{
|
class ExperienceManager{
|
||||||
|
|
||||||
@ -142,7 +144,12 @@ class ExperienceManager{
|
|||||||
public function setCurrentTotalXp(int $amount) : bool{
|
public function setCurrentTotalXp(int $amount) : bool{
|
||||||
$newLevel = ExperienceUtils::getLevelFromXp($amount);
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user