Import alias cleanup courtesy of newest php-cs-fixer

This commit is contained in:
Dylan K. Taylor 2024-02-07 12:50:37 +00:00
parent f54ed8362d
commit fe06bfcda0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
6 changed files with 72 additions and 69 deletions

View File

@ -21,6 +21,9 @@
declare(strict_types=1);
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\VersionInfo;
require dirname(__DIR__) . '/vendor/autoload.php';
if(count($argv) !== 7){
@ -30,12 +33,12 @@ if(count($argv) !== 7){
echo json_encode([
"php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION), //deprecated
"base_version" => \pocketmine\VersionInfo::BASE_VERSION,
"base_version" => VersionInfo::BASE_VERSION,
"build" => (int) $argv[4],
"is_dev" => \pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD,
"channel" => \pocketmine\VersionInfo::BUILD_CHANNEL,
"is_dev" => VersionInfo::IS_DEVELOPMENT_BUILD,
"channel" => VersionInfo::BUILD_CHANNEL,
"git_commit" => $argv[1],
"mcpe_version" => \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK,
"mcpe_version" => ProtocolInfo::MINECRAFT_VERSION_NETWORK,
"date" => time(), //TODO: maybe we should embed this in VersionInfo?
"details_url" => "https://github.com/$argv[3]/releases/tag/$argv[2]",
"download_url" => "https://github.com/$argv[3]/releases/download/$argv[2]/PocketMine-MP.phar",

View File

@ -739,7 +739,7 @@ class Server{
* @return string[][]
*/
public function getCommandAliases() : array{
$section = $this->configGroup->getProperty(YmlServerProperties::ALIASES);
$section = $this->configGroup->getProperty(Yml::ALIASES);
$result = [];
if(is_array($section)){
foreach($section as $key => $value){
@ -863,7 +863,7 @@ class Server{
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error1(VersionInfo::NAME)));
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error2()));
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error3()));
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error4(YmlServerProperties::SETTINGS_ENABLE_DEV_BUILDS)));
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error4(Yml::SETTINGS_ENABLE_DEV_BUILDS)));
$this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_server_devBuild_error5("https://github.com/pmmp/PocketMine-MP/releases")));
$this->forceShutdownExit();
@ -1476,7 +1476,7 @@ class Server{
}
if(isset($this->network)){
$this->network->getSessionManager()->close($this->configGroup->getPropertyString(YmlServerProperties::SETTINGS_SHUTDOWN_MESSAGE, "Server closed"));
$this->network->getSessionManager()->close($this->configGroup->getPropertyString(Yml::SETTINGS_SHUTDOWN_MESSAGE, "Server closed"));
}
if(isset($this->worldManager)){

View File

@ -788,7 +788,7 @@ final class VanillaBlocks{
}
protected static function setup() : void{
$railBreakInfo = new Info(new BlockBreakInfo(0.7));
$railBreakInfo = new Info(new BreakInfo(0.7));
self::register("activator_rail", new ActivatorRail(new BID(Ids::ACTIVATOR_RAIL), "Activator Rail", $railBreakInfo));
self::register("air", new Air(new BID(Ids::AIR), "Air", new Info(BreakInfo::indestructible(-1.0))));
self::register("anvil", new Anvil(new BID(Ids::ANVIL), "Anvil", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 6000.0))));
@ -1638,7 +1638,7 @@ final class VanillaBlocks{
self::register("cave_vines", new CaveVines(new BID(Ids::CAVE_VINES), "Cave Vines", new Info(BreakInfo::instant())));
self::register("small_dripleaf", new SmallDripleaf(new BID(Ids::SMALL_DRIPLEAF), "Small Dripleaf", new Info(BreakInfo::instant(BlockToolType::SHEARS, toolHarvestLevel: 1))));
self::register("small_dripleaf", new SmallDripleaf(new BID(Ids::SMALL_DRIPLEAF), "Small Dripleaf", new Info(BreakInfo::instant(ToolType::SHEARS, toolHarvestLevel: 1))));
self::register("big_dripleaf_head", new BigDripleafHead(new BID(Ids::BIG_DRIPLEAF_HEAD), "Big Dripleaf", new Info(BreakInfo::instant())));
self::register("big_dripleaf_stem", new BigDripleafStem(new BID(Ids::BIG_DRIPLEAF_STEM), "Big Dripleaf Stem", new Info(BreakInfo::instant())));
}

View File

@ -171,7 +171,7 @@ final class WoodLikeBlockIdHelper{
};
}
public static function getTrapdoorIdentifier(WoodType $treeType) : BlockIdentifier{
public static function getTrapdoorIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_TRAPDOOR,
WoodType::SPRUCE => Ids::SPRUCE_TRAPDOOR,
@ -186,7 +186,7 @@ final class WoodLikeBlockIdHelper{
});
}
public static function getButtonIdentifier(WoodType $treeType) : BlockIdentifier{
public static function getButtonIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_BUTTON,
WoodType::SPRUCE => Ids::SPRUCE_BUTTON,
@ -201,7 +201,7 @@ final class WoodLikeBlockIdHelper{
});
}
public static function getPressurePlateIdentifier(WoodType $treeType) : BlockIdentifier{
public static function getPressurePlateIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_PRESSURE_PLATE,
WoodType::SPRUCE => Ids::SPRUCE_PRESSURE_PLATE,
@ -216,7 +216,7 @@ final class WoodLikeBlockIdHelper{
});
}
public static function getDoorIdentifier(WoodType $treeType) : BlockIdentifier{
public static function getDoorIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_DOOR,
WoodType::SPRUCE => Ids::SPRUCE_DOOR,
@ -231,7 +231,7 @@ final class WoodLikeBlockIdHelper{
});
}
public static function getFenceGateIdentifier(WoodType $treeType) : BlockIdentifier{
public static function getFenceGateIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_FENCE_GATE,
WoodType::SPRUCE => Ids::SPRUCE_FENCE_GATE,
@ -246,7 +246,7 @@ final class WoodLikeBlockIdHelper{
});
}
public static function getStairsIdentifier(WoodType $treeType) : BlockIdentifier{
public static function getStairsIdentifier(WoodType $treeType) : BID{
return new BID(match($treeType){
WoodType::OAK => Ids::OAK_STAIRS,
WoodType::SPRUCE => Ids::SPRUCE_STAIRS,

View File

@ -57,42 +57,42 @@ use pocketmine\math\Facing;
final class BlockStateSerializerHelper{
public static function encodeAllSidedLog(Wood $block) : BlockStateWriter{
return BlockStateWriter::create(Ids::WOOD)
public static function encodeAllSidedLog(Wood $block) : Writer{
return Writer::create(Ids::WOOD)
->writeBool(BlockStateNames::STRIPPED_BIT, $block->isStripped())
->writePillarAxis($block->getAxis())
->writeLegacyWoodType($block->getWoodType());
}
public static function encodeButton(Button $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeButton(Button $block, Writer $out) : Writer{
return $out
->writeFacingDirection($block->getFacing())
->writeBool(BlockStateNames::BUTTON_PRESSED_BIT, $block->isPressed());
}
public static function encodeCandle(Candle $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeCandle(Candle $block, Writer $out) : Writer{
return $out
->writeBool(StateNames::LIT, $block->isLit())
->writeInt(StateNames::CANDLES, $block->getCount() - 1);
}
public static function encodeChemistryTable(ChemistryTable $block, string $chemistryTableType, BlockStateWriter $out) : BlockStateWriter{
public static function encodeChemistryTable(ChemistryTable $block, string $chemistryTableType, Writer $out) : Writer{
return $out
->writeString(BlockStateNames::CHEMISTRY_TABLE_TYPE, $chemistryTableType)
->writeLegacyHorizontalFacing(Facing::opposite($block->getFacing()));
}
public static function encodeCrops(Crops $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeCrops(Crops $block, Writer $out) : Writer{
return $out->writeInt(BlockStateNames::GROWTH, $block->getAge());
}
public static function encodeColoredTorch(Torch $block, bool $highBit, BlockStateWriter $out) : BlockStateWriter{
public static function encodeColoredTorch(Torch $block, bool $highBit, Writer $out) : Writer{
return $out
->writeBool(BlockStateNames::COLOR_BIT, $highBit)
->writeTorchFacing($block->getFacing());
}
public static function encodeCauldron(string $liquid, int $fillLevel) : BlockStateWriter{
public static function encodeCauldron(string $liquid, int $fillLevel) : Writer{
return Writer::create(Ids::CAULDRON)
->writeString(BlockStateNames::CAULDRON_LIQUID, $liquid)
->writeInt(BlockStateNames::FILL_LEVEL, $fillLevel);
@ -107,7 +107,7 @@ final class BlockStateSerializerHelper{
};
}
public static function encodeDoor(Door $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeDoor(Door $block, Writer $out) : Writer{
return $out
->writeBool(BlockStateNames::UPPER_BLOCK_BIT, $block->isTop())
->writeLegacyHorizontalFacing(Facing::rotateY($block->getFacing(), true))
@ -115,111 +115,111 @@ final class BlockStateSerializerHelper{
->writeBool(BlockStateNames::OPEN_BIT, $block->isOpen());
}
public static function encodeDoublePlant(DoublePlant $block, string $doublePlantType, BlockStateWriter $out) : BlockStateWriter{
public static function encodeDoublePlant(DoublePlant $block, string $doublePlantType, Writer $out) : Writer{
return $out
->writeBool(BlockStateNames::UPPER_BLOCK_BIT, $block->isTop())
->writeString(BlockStateNames::DOUBLE_PLANT_TYPE, $doublePlantType);
}
public static function encodeFenceGate(FenceGate $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeFenceGate(FenceGate $block, Writer $out) : Writer{
return $out
->writeLegacyHorizontalFacing($block->getFacing())
->writeBool(BlockStateNames::IN_WALL_BIT, $block->isInWall())
->writeBool(BlockStateNames::OPEN_BIT, $block->isOpen());
}
public static function encodeFloorSign(FloorSign $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeFloorSign(FloorSign $block, Writer $out) : Writer{
return $out
->writeInt(BlockStateNames::GROUND_SIGN_DIRECTION, $block->getRotation());
}
public static function encodeFurnace(Furnace $block, string $unlitId, string $litId) : BlockStateWriter{
return BlockStateWriter::create($block->isLit() ? $litId : $unlitId)
public static function encodeFurnace(Furnace $block, string $unlitId, string $litId) : Writer{
return Writer::create($block->isLit() ? $litId : $unlitId)
->writeCardinalHorizontalFacing($block->getFacing());
}
public static function encodeItemFrame(ItemFrame $block, string $id) : BlockStateWriter{
public static function encodeItemFrame(ItemFrame $block, string $id) : Writer{
return Writer::create($id)
->writeBool(StateNames::ITEM_FRAME_MAP_BIT, $block->hasMap())
->writeBool(StateNames::ITEM_FRAME_PHOTO_BIT, false)
->writeFacingDirection($block->getFacing());
}
public static function encodeLeaves(Leaves $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeLeaves(Leaves $block, Writer $out) : Writer{
return $out
->writeBool(BlockStateNames::PERSISTENT_BIT, $block->isNoDecay())
->writeBool(BlockStateNames::UPDATE_BIT, $block->isCheckDecay());
}
public static function encodeLeaves1(Leaves $block, string $type) : BlockStateWriter{
return self::encodeLeaves($block, BlockStateWriter::create(Ids::LEAVES)
public static function encodeLeaves1(Leaves $block, string $type) : Writer{
return self::encodeLeaves($block, Writer::create(Ids::LEAVES)
->writeString(BlockStateNames::OLD_LEAF_TYPE, $type));
}
public static function encodeLeaves2(Leaves $block, string $type) : BlockStateWriter{
return self::encodeLeaves($block, BlockStateWriter::create(Ids::LEAVES2)
public static function encodeLeaves2(Leaves $block, string $type) : Writer{
return self::encodeLeaves($block, Writer::create(Ids::LEAVES2)
->writeString(BlockStateNames::NEW_LEAF_TYPE, $type));
}
public static function encodeLiquid(Liquid $block, string $stillId, string $flowingId) : BlockStateWriter{
return BlockStateWriter::create($block->isStill() ? $stillId : $flowingId)
public static function encodeLiquid(Liquid $block, string $stillId, string $flowingId) : Writer{
return Writer::create($block->isStill() ? $stillId : $flowingId)
->writeInt(BlockStateNames::LIQUID_DEPTH, $block->getDecay() | ($block->isFalling() ? 0x8 : 0));
}
public static function encodeLog(Wood $block, string $unstrippedId, string $strippedId) : BlockStateWriter{
public static function encodeLog(Wood $block, string $unstrippedId, string $strippedId) : Writer{
$out = $block->isStripped() ?
BlockStateWriter::create($strippedId) :
BlockStateWriter::create($unstrippedId);
Writer::create($strippedId) :
Writer::create($unstrippedId);
return $out
->writePillarAxis($block->getAxis());
}
public static function encodeMushroomBlock(RedMushroomBlock $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeMushroomBlock(RedMushroomBlock $block, Writer $out) : Writer{
return $out
->writeInt(BlockStateNames::HUGE_MUSHROOM_BITS, MushroomBlockTypeIdMap::getInstance()->toId($block->getMushroomBlockType()));
}
public static function encodeQuartz(string $type, int $axis) : BlockStateWriter{
return BlockStateWriter::create(Ids::QUARTZ_BLOCK)
public static function encodeQuartz(string $type, int $axis) : Writer{
return Writer::create(Ids::QUARTZ_BLOCK)
->writeString(BlockStateNames::CHISEL_TYPE, $type)
->writePillarAxis($axis); //this isn't needed for all types, but we have to write it anyway
}
public static function encodeRedFlower(string $type) : BlockStateWriter{
return BlockStateWriter::create(Ids::RED_FLOWER)->writeString(BlockStateNames::FLOWER_TYPE, $type);
public static function encodeRedFlower(string $type) : Writer{
return Writer::create(Ids::RED_FLOWER)->writeString(BlockStateNames::FLOWER_TYPE, $type);
}
public static function encodeSandstone(string $id, string $type) : BlockStateWriter{
return BlockStateWriter::create($id)->writeString(BlockStateNames::SAND_STONE_TYPE, $type);
public static function encodeSandstone(string $id, string $type) : Writer{
return Writer::create($id)->writeString(BlockStateNames::SAND_STONE_TYPE, $type);
}
public static function encodeSapling(Sapling $block, string $type) : BlockStateWriter{
return BlockStateWriter::create(Ids::SAPLING)
public static function encodeSapling(Sapling $block, string $type) : Writer{
return Writer::create(Ids::SAPLING)
->writeBool(BlockStateNames::AGE_BIT, $block->isReady())
->writeString(BlockStateNames::SAPLING_TYPE, $type);
}
public static function encodeSimplePressurePlate(SimplePressurePlate $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeSimplePressurePlate(SimplePressurePlate $block, Writer $out) : Writer{
//TODO: not sure what the deal is here ... seems like a mojang bug / artifact of bad implementation?
//best to keep this separate from weighted plates anyway...
return $out
->writeInt(BlockStateNames::REDSTONE_SIGNAL, $block->isPressed() ? 15 : 0);
}
public static function encodeSlab(Slab $block, string $singleId, string $doubleId) : BlockStateWriter{
public static function encodeSlab(Slab $block, string $singleId, string $doubleId) : Writer{
$slabType = $block->getSlabType();
return BlockStateWriter::create($slabType === SlabType::DOUBLE ? $doubleId : $singleId)
return Writer::create($slabType === SlabType::DOUBLE ? $doubleId : $singleId)
//this is (intentionally) also written for double slabs (as zero) to maintain bug parity with MCPE
->writeSlabPosition($slabType === SlabType::DOUBLE ? SlabType::BOTTOM : $slabType);
}
public static function encodeStairs(Stair $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeStairs(Stair $block, Writer $out) : Writer{
return $out
->writeBool(BlockStateNames::UPSIDE_DOWN_BIT, $block->isUpsideDown())
->writeWeirdoHorizontalFacing($block->getFacing());
}
public static function encodeStem(Stem $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeStem(Stem $block, Writer $out) : Writer{
//In PM, we use Facing::UP to indicate that the stem is not attached to a pumpkin/melon, since this makes the
//most intuitive sense (the stem is pointing at the sky). However, Bedrock uses the DOWN state for this, which
//is absurd, and I refuse to make our API similarly absurd.
@ -228,40 +228,40 @@ final class BlockStateSerializerHelper{
->writeFacingWithoutUp($facing === Facing::UP ? Facing::DOWN : $facing);
}
public static function encodeStoneBricks(string $type) : BlockStateWriter{
return BlockStateWriter::create(Ids::STONEBRICK)
public static function encodeStoneBricks(string $type) : Writer{
return Writer::create(Ids::STONEBRICK)
->writeString(BlockStateNames::STONE_BRICK_TYPE, $type);
}
private static function encodeStoneSlab(Slab $block, string $singleId, string $doubleId, string $typeKey, string $typeValue) : BlockStateWriter{
private static function encodeStoneSlab(Slab $block, string $singleId, string $doubleId, string $typeKey, string $typeValue) : Writer{
return self::encodeSlab($block, $singleId, $doubleId)
->writeString($typeKey, $typeValue);
}
public static function encodeStoneSlab1(Slab $block, string $typeValue) : BlockStateWriter{
public static function encodeStoneSlab1(Slab $block, string $typeValue) : Writer{
return self::encodeStoneSlab($block, Ids::STONE_BLOCK_SLAB, Ids::DOUBLE_STONE_BLOCK_SLAB, BlockStateNames::STONE_SLAB_TYPE, $typeValue);
}
public static function encodeStoneSlab2(Slab $block, string $typeValue) : BlockStateWriter{
public static function encodeStoneSlab2(Slab $block, string $typeValue) : Writer{
return self::encodeStoneSlab($block, Ids::STONE_BLOCK_SLAB2, Ids::DOUBLE_STONE_BLOCK_SLAB2, BlockStateNames::STONE_SLAB_TYPE_2, $typeValue);
}
public static function encodeStoneSlab3(Slab $block, string $typeValue) : BlockStateWriter{
public static function encodeStoneSlab3(Slab $block, string $typeValue) : Writer{
return self::encodeStoneSlab($block, Ids::STONE_BLOCK_SLAB3, Ids::DOUBLE_STONE_BLOCK_SLAB3, BlockStateNames::STONE_SLAB_TYPE_3, $typeValue);
}
public static function encodeStoneSlab4(Slab $block, string $typeValue) : BlockStateWriter{
public static function encodeStoneSlab4(Slab $block, string $typeValue) : Writer{
return self::encodeStoneSlab($block, Ids::STONE_BLOCK_SLAB4, Ids::DOUBLE_STONE_BLOCK_SLAB4, BlockStateNames::STONE_SLAB_TYPE_4, $typeValue);
}
public static function encodeTrapdoor(Trapdoor $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeTrapdoor(Trapdoor $block, Writer $out) : Writer{
return $out
->write5MinusHorizontalFacing($block->getFacing())
->writeBool(BlockStateNames::UPSIDE_DOWN_BIT, $block->isTop())
->writeBool(BlockStateNames::OPEN_BIT, $block->isOpen());
}
public static function encodeWall(Wall $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeWall(Wall $block, Writer $out) : Writer{
return $out
->writeBool(BlockStateNames::WALL_POST_BIT, $block->isPost())
->writeWallConnectionType(BlockStateNames::WALL_CONNECTION_TYPE_EAST, $block->getConnection(Facing::EAST))
@ -270,17 +270,17 @@ final class BlockStateSerializerHelper{
->writeWallConnectionType(BlockStateNames::WALL_CONNECTION_TYPE_WEST, $block->getConnection(Facing::WEST));
}
public static function encodeLegacyWall(Wall $block, string $type) : BlockStateWriter{
return self::encodeWall($block, BlockStateWriter::create(Ids::COBBLESTONE_WALL))
public static function encodeLegacyWall(Wall $block, string $type) : Writer{
return self::encodeWall($block, Writer::create(Ids::COBBLESTONE_WALL))
->writeString(BlockStateNames::WALL_BLOCK_TYPE, $type);
}
public static function encodeWallSign(WallSign $block, BlockStateWriter $out) : BlockStateWriter{
public static function encodeWallSign(WallSign $block, Writer $out) : Writer{
return $out
->writeHorizontalFacing($block->getFacing());
}
public static function encodeWoodenSlab(Slab $block, string $typeValue) : BlockStateWriter{
public static function encodeWoodenSlab(Slab $block, string $typeValue) : Writer{
return self::encodeSlab($block, Ids::WOODEN_SLAB, Ids::DOUBLE_WOODEN_SLAB)
->writeString(BlockStateNames::WOOD_TYPE, $typeValue);
}

View File

@ -30,7 +30,7 @@ require dirname(__DIR__, 3) . '/vendor/autoload.php';
/* This script needs to be re-run after any intentional blockfactory change (adding or removing a block state). */
$factory = new \pocketmine\block\RuntimeBlockStateRegistry();
$factory = new RuntimeBlockStateRegistry();
$remaps = [];
$new = [];
foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $index => $block){
@ -44,7 +44,7 @@ $oldTablePath = __DIR__ . '/block_factory_consistency_check.json';
if(file_exists($oldTablePath)){
$oldTable = json_decode(file_get_contents($oldTablePath), true);
if(!is_array($oldTable)){
throw new \pocketmine\utils\AssumptionFailedError("Old table should be array{knownStates: array<string, string>, stateDataBits: int}");
throw new AssumptionFailedError("Old table should be array{knownStates: array<string, string>, stateDataBits: int}");
}
$old = [];
/**