mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Allow remapped oldState and newState to accept null, to make it easier for third-party tools to use the schemas
since PHP emits empty JSON objects as arrays, this makes it pretty annoying to work with the schemas in other languages. However, nullability is something most languages understand pretty easily. This should continue to support old schemas.
This commit is contained in:
parent
341a9b78b5
commit
0818388bd5
@ -150,9 +150,9 @@ final class BlockStateUpgradeSchemaUtils{
|
||||
foreach(Utils::stringifyKeys($model->remappedStates ?? []) as $oldBlockName => $remaps){
|
||||
foreach($remaps as $remap){
|
||||
$result->remappedStates[$oldBlockName][] = new BlockStateUpgradeSchemaBlockRemap(
|
||||
array_map(fn(BlockStateUpgradeSchemaModelTag $tag) => self::jsonModelToTag($tag), $remap->oldState),
|
||||
array_map(fn(BlockStateUpgradeSchemaModelTag $tag) => self::jsonModelToTag($tag), $remap->oldState ?? []),
|
||||
$remap->newName,
|
||||
array_map(fn(BlockStateUpgradeSchemaModelTag $tag) => self::jsonModelToTag($tag), $remap->newState),
|
||||
array_map(fn(BlockStateUpgradeSchemaModelTag $tag) => self::jsonModelToTag($tag), $remap->newState ?? []),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,24 +23,25 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\bedrock\block\upgrade\model;
|
||||
|
||||
use function count;
|
||||
|
||||
final class BlockStateUpgradeSchemaModelBlockRemap{
|
||||
|
||||
/**
|
||||
* @var BlockStateUpgradeSchemaModelTag[]
|
||||
* @phpstan-var array<string, BlockStateUpgradeSchemaModelTag>
|
||||
* @var BlockStateUpgradeSchemaModelTag[]|null
|
||||
* @phpstan-var array<string, BlockStateUpgradeSchemaModelTag>|null
|
||||
* @required
|
||||
*/
|
||||
public array $oldState;
|
||||
public ?array $oldState;
|
||||
|
||||
/** @required */
|
||||
public string $newName;
|
||||
|
||||
/**
|
||||
* @var BlockStateUpgradeSchemaModelTag[]
|
||||
* @phpstan-var array<string, BlockStateUpgradeSchemaModelTag>
|
||||
* @required
|
||||
* @var BlockStateUpgradeSchemaModelTag[]|null
|
||||
* @phpstan-var array<string, BlockStateUpgradeSchemaModelTag>|null
|
||||
*/
|
||||
public array $newState;
|
||||
public ?array $newState;
|
||||
|
||||
/**
|
||||
* @param BlockStateUpgradeSchemaModelTag[] $oldState
|
||||
@ -49,8 +50,8 @@ final class BlockStateUpgradeSchemaModelBlockRemap{
|
||||
* @phpstan-param array<string, BlockStateUpgradeSchemaModelTag> $newState
|
||||
*/
|
||||
public function __construct(array $oldState, string $newName, array $newState){
|
||||
$this->oldState = $oldState;
|
||||
$this->oldState = count($oldState) === 0 ? null : $oldState;
|
||||
$this->newName = $newName;
|
||||
$this->newState = $newState;
|
||||
$this->newState = count($newState) === 0 ? null : $newState;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user