Make blockstate (de)serializer names a bit less verbose

This commit is contained in:
Dylan K. Taylor 2022-09-24 13:43:00 +01:00
parent cf9610c710
commit 1609b11c8e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 14 additions and 14 deletions

View File

@ -169,7 +169,7 @@ use pocketmine\utils\AssumptionFailedError;
use function class_parents; use function class_parents;
use function get_class; use function get_class;
final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{ final class BlockObjectToStateSerializer implements BlockStateSerializer{
/** /**
* These callables actually accept Block, but for the sake of type completeness, it has to be never, since we can't * These callables actually accept Block, but for the sake of type completeness, it has to be never, since we can't
* describe the bottom type of a type hierarchy only containing Block. * describe the bottom type of a type hierarchy only containing Block.

View File

@ -54,7 +54,7 @@ use function array_key_exists;
use function count; use function count;
use function min; use function min;
final class BlockStateToBlockObjectDeserializer implements BlockStateDeserializer{ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
/** /**
* @var \Closure[] * @var \Closure[]

View File

@ -25,8 +25,8 @@ namespace pocketmine\world\format\io;
use pocketmine\data\bedrock\block\BlockStateData; use pocketmine\data\bedrock\block\BlockStateData;
use pocketmine\data\bedrock\block\BlockTypeNames; use pocketmine\data\bedrock\block\BlockTypeNames;
use pocketmine\data\bedrock\block\convert\BlockObjectToBlockStateSerializer; use pocketmine\data\bedrock\block\convert\BlockObjectToStateSerializer;
use pocketmine\data\bedrock\block\convert\BlockStateToBlockObjectDeserializer; use pocketmine\data\bedrock\block\convert\BlockStateToObjectDeserializer;
use pocketmine\data\bedrock\block\upgrade\BlockDataUpgrader; use pocketmine\data\bedrock\block\upgrade\BlockDataUpgrader;
use pocketmine\data\bedrock\block\upgrade\BlockIdMetaUpgrader; use pocketmine\data\bedrock\block\upgrade\BlockIdMetaUpgrader;
use pocketmine\data\bedrock\block\upgrade\BlockStateUpgrader; use pocketmine\data\bedrock\block\upgrade\BlockStateUpgrader;
@ -45,20 +45,20 @@ use const pocketmine\BEDROCK_BLOCK_UPGRADE_SCHEMA_PATH;
*/ */
final class GlobalBlockStateHandlers{ final class GlobalBlockStateHandlers{
private static ?BlockObjectToBlockStateSerializer $blockStateSerializer = null; private static ?BlockObjectToStateSerializer $blockStateSerializer = null;
private static ?BlockStateToBlockObjectDeserializer $blockStateDeserializer = null; private static ?BlockStateToObjectDeserializer $blockStateDeserializer = null;
private static ?BlockDataUpgrader $blockDataUpgrader = null; private static ?BlockDataUpgrader $blockDataUpgrader = null;
private static ?BlockStateData $unknownBlockStateData = null; private static ?BlockStateData $unknownBlockStateData = null;
public static function getDeserializer() : BlockStateToBlockObjectDeserializer{ public static function getDeserializer() : BlockStateToObjectDeserializer{
return self::$blockStateDeserializer ??= new BlockStateToBlockObjectDeserializer(); return self::$blockStateDeserializer ??= new BlockStateToObjectDeserializer();
} }
public static function getSerializer() : BlockObjectToBlockStateSerializer{ public static function getSerializer() : BlockObjectToStateSerializer{
return self::$blockStateSerializer ??= new BlockObjectToBlockStateSerializer(); return self::$blockStateSerializer ??= new BlockObjectToStateSerializer();
} }
public static function getUpgrader() : BlockDataUpgrader{ public static function getUpgrader() : BlockDataUpgrader{

View File

@ -34,12 +34,12 @@ use pocketmine\data\bedrock\block\BlockStateSerializeException;
use function print_r; use function print_r;
final class BlockSerializerDeserializerTest extends TestCase{ final class BlockSerializerDeserializerTest extends TestCase{
private BlockStateToBlockObjectDeserializer $deserializer; private BlockStateToObjectDeserializer $deserializer;
private BlockObjectToBlockStateSerializer $serializer; private BlockObjectToStateSerializer $serializer;
public function setUp() : void{ public function setUp() : void{
$this->deserializer = new BlockStateToBlockObjectDeserializer(); $this->deserializer = new BlockStateToObjectDeserializer();
$this->serializer = new BlockObjectToBlockStateSerializer(); $this->serializer = new BlockObjectToStateSerializer();
} }
public function testAllKnownBlockStatesSerializableAndDeserializable() : void{ public function testAllKnownBlockStatesSerializableAndDeserializable() : void{