diff --git a/changelogs/4.0.md b/changelogs/4.0.md index 7f5a25a91..6a97299c3 100644 --- a/changelogs/4.0.md +++ b/changelogs/4.0.md @@ -1026,6 +1026,7 @@ However, if we add `src-namespace-prefix: pmmp\TesterPlugin` to the `plugin.yml` - `Player->continueBreakBlock()`: punch the target block during destruction in survival, advancing break animation and creating particles - `Player->getCurrentWindow()`: returns the inventory window the player is currently viewing, or null if they aren't viewing an inventory - `Player->getItemCooldownExpiry()`: returns the tick on which the player's cooldown for a given item expires + - `Player->getLowerCaseName()`: use `strtolower(Player->getName())` instead - `Player->getPlayerInfo()`: returns a `PlayerInfo` object containing various metadata about the player - `Player->getSaveData()`: returns save data generated on the fly - `Player->hasFiniteResources()` diff --git a/composer.lock b/composer.lock index 284b6914d..2979bb4ab 100644 --- a/composer.lock +++ b/composer.lock @@ -322,16 +322,16 @@ }, { "name": "pocketmine/binaryutils", - "version": "0.2.2", + "version": "0.2.3", "source": { "type": "git", "url": "https://github.com/pmmp/BinaryUtils.git", - "reference": "f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9" + "reference": "dc94786fc6c30012b1892f548dbb8a8c9c0a8cd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9", - "reference": "f883e1cf9099ed6a757a10a2f75b3333eeb2cdf9", + "url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/dc94786fc6c30012b1892f548dbb8a8c9c0a8cd9", + "reference": "dc94786fc6c30012b1892f548dbb8a8c9c0a8cd9", "shasum": "" }, "require": { @@ -340,8 +340,10 @@ }, "require-dev": { "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-strict-rules": "^0.12.4" + "phpstan/phpstan": "1.2.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0.0", + "phpunit/phpunit": "^9.5" }, "type": "library", "autoload": { @@ -356,9 +358,9 @@ "description": "Classes and methods for conveniently handling binary data", "support": { "issues": "https://github.com/pmmp/BinaryUtils/issues", - "source": "https://github.com/pmmp/BinaryUtils/tree/0.2.2" + "source": "https://github.com/pmmp/BinaryUtils/tree/0.2.3" }, - "time": "2021-10-22T19:54:16+00:00" + "time": "2021-12-04T20:56:05+00:00" }, { "name": "pocketmine/callback-validator", @@ -533,16 +535,16 @@ }, { "name": "pocketmine/locale-data", - "version": "2.0.20", + "version": "2.0.22", "source": { "type": "git", "url": "https://github.com/pmmp/Language.git", - "reference": "a6e4eb22587e0014f6d658732cf633262723f8d3" + "reference": "181eb9d42653296e65d55a1bbba10e0dd76bbd61" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Language/zipball/a6e4eb22587e0014f6d658732cf633262723f8d3", - "reference": "a6e4eb22587e0014f6d658732cf633262723f8d3", + "url": "https://api.github.com/repos/pmmp/Language/zipball/181eb9d42653296e65d55a1bbba10e0dd76bbd61", + "reference": "181eb9d42653296e65d55a1bbba10e0dd76bbd61", "shasum": "" }, "type": "library", @@ -550,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.20" + "source": "https://github.com/pmmp/Language/tree/2.0.22" }, - "time": "2021-11-25T20:56:12+00:00" + "time": "2021-12-04T22:37:10+00:00" }, { "name": "pocketmine/log", @@ -641,16 +643,16 @@ }, { "name": "pocketmine/math", - "version": "0.4.0", + "version": "0.4.2", "source": { "type": "git", "url": "https://github.com/pmmp/Math.git", - "reference": "6d64e2555bd2e95ed024574f75d1cefc135c89fc" + "reference": "aacc3759a508a69dfa5bc4dfa770ab733c5c94bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Math/zipball/6d64e2555bd2e95ed024574f75d1cefc135c89fc", - "reference": "6d64e2555bd2e95ed024574f75d1cefc135c89fc", + "url": "https://api.github.com/repos/pmmp/Math/zipball/aacc3759a508a69dfa5bc4dfa770ab733c5c94bf", + "reference": "aacc3759a508a69dfa5bc4dfa770ab733c5c94bf", "shasum": "" }, "require": { @@ -658,10 +660,10 @@ "php-64bit": "*" }, "require-dev": { - "irstea/phpunit-shim": "^8.5 || ^9.5", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-strict-rules": "^0.12.4" + "phpstan/phpstan": "1.2.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^8.5 || ^9.5" }, "type": "library", "autoload": { @@ -676,22 +678,22 @@ "description": "PHP library containing math related code used in PocketMine-MP", "support": { "issues": "https://github.com/pmmp/Math/issues", - "source": "https://github.com/pmmp/Math/tree/0.4.0" + "source": "https://github.com/pmmp/Math/tree/0.4.2" }, - "time": "2021-10-29T20:33:10+00:00" + "time": "2021-12-05T01:15:17+00:00" }, { "name": "pocketmine/nbt", - "version": "0.3.0", + "version": "0.3.1", "source": { "type": "git", "url": "https://github.com/pmmp/NBT.git", - "reference": "98c4a04b55a915e18f83d3b0c9beb24a71abcd31" + "reference": "f43db89b8216b772407cdcedd90147db8eef34bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/NBT/zipball/98c4a04b55a915e18f83d3b0c9beb24a71abcd31", - "reference": "98c4a04b55a915e18f83d3b0c9beb24a71abcd31", + "url": "https://api.github.com/repos/pmmp/NBT/zipball/f43db89b8216b772407cdcedd90147db8eef34bc", + "reference": "f43db89b8216b772407cdcedd90147db8eef34bc", "shasum": "" }, "require": { @@ -702,7 +704,7 @@ "require-dev": { "irstea/phpunit-shim": "^9.5", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.85", + "phpstan/phpstan": "0.12.99", "phpstan/phpstan-strict-rules": "^0.12.4" }, "type": "library", @@ -718,9 +720,9 @@ "description": "PHP library for working with Named Binary Tags", "support": { "issues": "https://github.com/pmmp/NBT/issues", - "source": "https://github.com/pmmp/NBT/tree/0.3.0" + "source": "https://github.com/pmmp/NBT/tree/0.3.1" }, - "time": "2021-05-18T15:46:33+00:00" + "time": "2021-12-06T16:19:10+00:00" }, { "name": "pocketmine/raklib", @@ -1504,16 +1506,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.13.1", + "version": "v4.13.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" + "reference": "210577fe3cf7badcc5814d99455df46564f3c077" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077", "shasum": "" }, "require": { @@ -1554,9 +1556,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" }, - "time": "2021-11-03T20:52:16+00:00" + "time": "2021-11-30T19:35:32+00:00" }, { "name": "phar-io/manifest", @@ -2068,16 +2070,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.9", + "version": "9.2.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "shasum": "" }, "require": { @@ -2133,7 +2135,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" }, "funding": [ { @@ -2141,20 +2143,20 @@ "type": "github" } ], - "time": "2021-11-19T15:21:02+00:00" + "time": "2021-12-05T09:12:13+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.5", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { @@ -2193,7 +2195,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -2201,7 +2203,7 @@ "type": "github" } ], - "time": "2020-09-28T05:57:25+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { "name": "phpunit/php-invoker", diff --git a/src/entity/object/FallingBlock.php b/src/entity/object/FallingBlock.php index 5376b866e..9957453b6 100644 --- a/src/entity/object/FallingBlock.php +++ b/src/entity/object/FallingBlock.php @@ -26,6 +26,7 @@ namespace pocketmine\entity\object; use pocketmine\block\Block; use pocketmine\block\BlockFactory; use pocketmine\block\utils\Fallable; +use pocketmine\data\SavedDataLoadingException; use pocketmine\entity\Entity; use pocketmine\entity\EntitySizeInfo; use pocketmine\entity\Location; @@ -71,7 +72,7 @@ class FallingBlock extends Entity{ } if($blockId === 0){ - throw new \UnexpectedValueException("Missing block info from NBT"); + throw new SavedDataLoadingException("Missing block info from NBT"); } $damage = $nbt->getByte("Data", 0); diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index df0b8944f..e2ae03a97 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -97,7 +97,7 @@ final class StringToItemParser extends StringToTParser{ $result->registerBlock("anvil", fn() => VanillaBlocks::ANVIL()); $result->registerBlock("ateupd_block", fn() => VanillaBlocks::INFO_UPDATE2()); $result->registerBlock("azure_bluet", fn() => VanillaBlocks::AZURE_BLUET()); - $result->registerBlock("bamboo", fn() => VanillaBlocks::BAMBOO_SAPLING()); + $result->registerBlock("bamboo", fn() => VanillaBlocks::BAMBOO()); $result->registerBlock("bamboo_sapling", fn() => VanillaBlocks::BAMBOO_SAPLING()); $result->registerBlock("banner", fn() => VanillaBlocks::BANNER()); $result->registerBlock("barrel", fn() => VanillaBlocks::BARREL()); @@ -798,13 +798,15 @@ final class StringToItemParser extends StringToTParser{ $result->registerBlock("sea_lantern", fn() => VanillaBlocks::SEA_LANTERN()); $result->registerBlock("sea_pickle", fn() => VanillaBlocks::SEA_PICKLE()); $result->registerBlock("sealantern", fn() => VanillaBlocks::SEA_LANTERN()); - $result->registerBlock("shulker_box", fn() => VanillaBlocks::DYED_SHULKER_BOX()); + $result->registerBlock("shulker_box", fn() => VanillaBlocks::SHULKER_BOX()); $result->registerBlock("sign", fn() => VanillaBlocks::OAK_SIGN()); $result->registerBlock("sign_post", fn() => VanillaBlocks::OAK_SIGN()); $result->registerBlock("silver_glazed_terracotta", fn() => VanillaBlocks::LIGHT_GRAY_GLAZED_TERRACOTTA()); $result->registerBlock("skull_block", fn() => VanillaBlocks::MOB_HEAD()); $result->registerBlock("slab", fn() => VanillaBlocks::SMOOTH_STONE_SLAB()); $result->registerBlock("slabs", fn() => VanillaBlocks::SMOOTH_STONE_SLAB()); + $result->registerBlock("slime", fn() => VanillaBlocks::SLIME()); + $result->registerBlock("slime_block", fn() => VanillaBlocks::SLIME()); $result->registerBlock("smoker", fn() => VanillaBlocks::SMOKER()); $result->registerBlock("smooth_quartz", fn() => VanillaBlocks::SMOOTH_QUARTZ()); $result->registerBlock("smooth_quartz_slab", fn() => VanillaBlocks::SMOOTH_QUARTZ_SLAB()); @@ -859,11 +861,11 @@ final class StringToItemParser extends StringToTParser{ $result->registerBlock("stone_bricks", fn() => VanillaBlocks::STONE_BRICKS()); $result->registerBlock("stone_button", fn() => VanillaBlocks::STONE_BUTTON()); $result->registerBlock("stone_pressure_plate", fn() => VanillaBlocks::STONE_PRESSURE_PLATE()); - $result->registerBlock("stone_slab", fn() => VanillaBlocks::SMOOTH_STONE_SLAB()); + $result->registerBlock("stone_slab", fn() => VanillaBlocks::STONE_SLAB()); $result->registerBlock("stone_slab2", fn() => VanillaBlocks::RED_SANDSTONE_SLAB()); $result->registerBlock("stone_slab3", fn() => VanillaBlocks::END_STONE_BRICK_SLAB()); $result->registerBlock("stone_slab4", fn() => VanillaBlocks::MOSSY_STONE_BRICK_SLAB()); - $result->registerBlock("stone_stairs", fn() => VanillaBlocks::COBBLESTONE_STAIRS()); + $result->registerBlock("stone_stairs", fn() => VanillaBlocks::STONE_STAIRS()); $result->registerBlock("stone_wall", fn() => VanillaBlocks::COBBLESTONE_WALL()); $result->registerBlock("stonebrick", fn() => VanillaBlocks::STONE_BRICKS()); $result->registerBlock("stonecutter", fn() => VanillaBlocks::LEGACY_STONECUTTER()); @@ -885,7 +887,7 @@ final class StringToItemParser extends StringToTParser{ $result->registerBlock("sugarcane_block", fn() => VanillaBlocks::SUGARCANE()); $result->registerBlock("sunflower", fn() => VanillaBlocks::SUNFLOWER()); $result->registerBlock("sweet_berry_bush", fn() => VanillaBlocks::SWEET_BERRY_BUSH()); - $result->registerBlock("tall_grass", fn() => VanillaBlocks::FERN()); + $result->registerBlock("tall_grass", fn() => VanillaBlocks::TALL_GRASS()); $result->registerBlock("tallgrass", fn() => VanillaBlocks::FERN()); $result->registerBlock("terracotta", fn() => VanillaBlocks::STAINED_CLAY()); $result->registerBlock("tnt", fn() => VanillaBlocks::TNT()); diff --git a/tests/phpunit/inventory/BaseInventoryTest.php b/tests/phpunit/inventory/BaseInventoryTest.php index 0354b2696..39ddd34ac 100644 --- a/tests/phpunit/inventory/BaseInventoryTest.php +++ b/tests/phpunit/inventory/BaseInventoryTest.php @@ -25,16 +25,14 @@ namespace pocketmine\inventory; use PHPUnit\Framework\TestCase; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; -use pocketmine\item\ItemIds; use pocketmine\item\VanillaItems; class BaseInventoryTest extends TestCase{ public function testAddItemDifferentUserData() : void{ $inv = new SimpleInventory(1); - $item1 = ItemFactory::getInstance()->get(ItemIds::ARROW, 0, 1); - $item2 = ItemFactory::getInstance()->get(ItemIds::ARROW, 0, 1)->setCustomName("TEST"); + $item1 = VanillaItems::ARROW()->setCount(1); + $item2 = VanillaItems::ARROW()->setCount(1)->setCustomName("TEST"); $inv->addItem(clone $item1); self::assertFalse($inv->canAddItem($item2), "Item WITHOUT userdata should not stack with item WITH userdata"); diff --git a/tests/phpunit/item/ItemTest.php b/tests/phpunit/item/ItemTest.php index 846b23f5f..95aafd8a7 100644 --- a/tests/phpunit/item/ItemTest.php +++ b/tests/phpunit/item/ItemTest.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\item; use PHPUnit\Framework\TestCase; +use pocketmine\block\VanillaBlocks; use pocketmine\item\enchantment\EnchantmentInstance; use pocketmine\item\enchantment\VanillaEnchantments; @@ -33,14 +34,14 @@ class ItemTest extends TestCase{ private $item; public function setUp() : void{ - $this->item = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD); + $this->item = VanillaItems::DIAMOND_SWORD(); } /** * Test for issue #1145 (items aren't considered equal after NBT serializing and deserializing */ public function testItemEquals() : void{ - $item = ItemFactory::getInstance()->get(ItemIds::STONE)->setCustomName("HI"); + $item = VanillaBlocks::STONE()->asItem()->setCustomName("HI"); $item2 = Item::nbtDeserialize($item->nbtSerialize()); self::assertTrue($item2->equals($item)); self::assertTrue($item->equals($item2)); @@ -50,7 +51,7 @@ class ItemTest extends TestCase{ * Test that same items without NBT are considered equal */ public function testItemEqualsNoNbt() : void{ - $item1 = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD); + $item1 = VanillaItems::DIAMOND_SWORD(); $item2 = clone $item1; self::assertTrue($item1->equals($item2)); } @@ -62,7 +63,7 @@ class ItemTest extends TestCase{ public function testItemPersistsDisplayProperties() : void{ $lore = ["Line A", "Line B"]; $name = "HI"; - $item = ItemFactory::getInstance()->get(ItemIds::DIAMOND_SWORD); + $item = VanillaItems::DIAMOND_SWORD(); $item->setCustomName($name); $item->setLore($lore); $item = Item::nbtDeserialize($item->nbtSerialize());