Merge branch 'stable' into minor-next

This commit is contained in:
Dylan K. Taylor
2024-11-25 14:32:30 +00:00
67 changed files with 339 additions and 130 deletions

View File

@ -33,7 +33,10 @@ use function spl_object_id;
* The primary purpose of this trait is providing scope isolation for the methods it contains.
*/
trait ItemEnchantmentHandlingTrait{
/** @var EnchantmentInstance[] */
/**
* @var EnchantmentInstance[]
* @phpstan-var array<int, EnchantmentInstance>
*/
protected array $enchantments = [];
public function hasEnchantments() : bool{
@ -79,6 +82,7 @@ trait ItemEnchantmentHandlingTrait{
/**
* @return EnchantmentInstance[]
* @phpstan-return array<int, EnchantmentInstance>
*/
public function getEnchantments() : array{
return $this->enchantments;

View File

@ -29,6 +29,7 @@ use pocketmine\data\bedrock\item\upgrade\ItemDataUpgrader;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Filesystem;
use pocketmine\utils\SingletonTrait;
use pocketmine\utils\Utils;
use pocketmine\world\format\io\GlobalItemDataHandlers;
use Symfony\Component\Filesystem\Path;
use function explode;
@ -67,7 +68,7 @@ final class LegacyStringToItemParser{
$mappings = json_decode($mappingsRaw, true);
if(!is_array($mappings)) throw new AssumptionFailedError("Invalid mappings format, expected array");
foreach($mappings as $name => $id){
foreach(Utils::promoteKeys($mappings) as $name => $id){
if(!is_string($id)) throw new AssumptionFailedError("Invalid mappings format, expected string values");
$result->addMapping((string) $name, $id);
}