Start migrating EnumTrait enums to PHP 8.1 native enums

This commit is contained in:
Dylan K. Taylor
2023-09-07 17:20:52 +01:00
parent fe94379a93
commit ae564e445d
131 changed files with 1157 additions and 1349 deletions

View File

@ -211,10 +211,10 @@ final class CraftingManagerFromDataHelper{
foreach(self::loadJsonArrayOfObjectsFile(Path::join($directoryPath, 'shapeless_crafting.json'), ShapelessRecipeData::class) as $recipe){
$recipeType = match($recipe->block){
"crafting_table" => ShapelessRecipeType::CRAFTING(),
"stonecutter" => ShapelessRecipeType::STONECUTTER(),
"smithing_table" => ShapelessRecipeType::SMITHING(),
"cartography_table" => ShapelessRecipeType::CARTOGRAPHY(),
"crafting_table" => ShapelessRecipeType::CRAFTING,
"stonecutter" => ShapelessRecipeType::STONECUTTER,
"smithing_table" => ShapelessRecipeType::SMITHING,
"cartography_table" => ShapelessRecipeType::CARTOGRAPHY,
default => null
};
if($recipeType === null){

View File

@ -23,28 +23,22 @@ declare(strict_types=1);
namespace pocketmine\crafting;
use pocketmine\utils\EnumTrait;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* This doc-block is generated automatically, do not modify it manually.
* This must be regenerated whenever registry members are added, removed or changed.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static ShapelessRecipeType CARTOGRAPHY()
* @method static ShapelessRecipeType CRAFTING()
* @method static ShapelessRecipeType SMITHING()
* @method static ShapelessRecipeType STONECUTTER()
*/
final class ShapelessRecipeType{
use EnumTrait;
enum ShapelessRecipeType{
use LegacyEnumShimTrait;
protected static function setup() : void{
self::registerAll(
new self("crafting"),
new self("stonecutter"),
new self("smithing"),
new self("cartography")
);
}
case CRAFTING;
case STONECUTTER;
case SMITHING;
case CARTOGRAPHY;
}