Strip out deprecated stuff

This commit is contained in:
Dylan K. Taylor 2023-09-07 20:26:04 +01:00
parent cd6b780d31
commit 89f42c80d4
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
47 changed files with 11 additions and 1004 deletions

View File

@ -750,8 +750,8 @@ use function strtolower;
* @method static Water WATER()
* @method static WaterCauldron WATER_CAULDRON()
* @method static NetherVines WEEPING_VINES()
* @method static WeightedPressurePlateHeavy WEIGHTED_PRESSURE_PLATE_HEAVY()
* @method static WeightedPressurePlateLight WEIGHTED_PRESSURE_PLATE_LIGHT()
* @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_HEAVY()
* @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_LIGHT()
* @method static Wheat WHEAT()
* @method static Flower WHITE_TULIP()
* @method static WitherRose WITHER_ROSE()
@ -1115,14 +1115,14 @@ final class VanillaBlocks{
self::register("lily_pad", new WaterLily(new BID(Ids::LILY_PAD), "Lily Pad", new Info(BreakInfo::instant())));
$weightedPressurePlateBreakInfo = new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD));
self::register("weighted_pressure_plate_heavy", new WeightedPressurePlateHeavy(
self::register("weighted_pressure_plate_heavy", new WeightedPressurePlate(
new BID(Ids::WEIGHTED_PRESSURE_PLATE_HEAVY),
"Weighted Pressure Plate Heavy",
$weightedPressurePlateBreakInfo,
deactivationDelayTicks: 10,
signalStrengthFactor: 0.1
));
self::register("weighted_pressure_plate_light", new WeightedPressurePlateLight(
self::register("weighted_pressure_plate_light", new WeightedPressurePlate(
new BID(Ids::WEIGHTED_PRESSURE_PLATE_LIGHT),
"Weighted Pressure Plate Light",
$weightedPressurePlateBreakInfo,

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
/**
* @deprecated
*/
class WeightedPressurePlateHeavy extends WeightedPressurePlate{
}

View File

@ -1,31 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
/**
* @deprecated
*/
class WeightedPressurePlateLight extends WeightedPressurePlate{
}

View File

@ -23,54 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BannerPatternType BORDER()
* @method static BannerPatternType BRICKS()
* @method static BannerPatternType CIRCLE()
* @method static BannerPatternType CREEPER()
* @method static BannerPatternType CROSS()
* @method static BannerPatternType CURLY_BORDER()
* @method static BannerPatternType DIAGONAL_LEFT()
* @method static BannerPatternType DIAGONAL_RIGHT()
* @method static BannerPatternType DIAGONAL_UP_LEFT()
* @method static BannerPatternType DIAGONAL_UP_RIGHT()
* @method static BannerPatternType FLOWER()
* @method static BannerPatternType GRADIENT()
* @method static BannerPatternType GRADIENT_UP()
* @method static BannerPatternType HALF_HORIZONTAL()
* @method static BannerPatternType HALF_HORIZONTAL_BOTTOM()
* @method static BannerPatternType HALF_VERTICAL()
* @method static BannerPatternType HALF_VERTICAL_RIGHT()
* @method static BannerPatternType MOJANG()
* @method static BannerPatternType RHOMBUS()
* @method static BannerPatternType SKULL()
* @method static BannerPatternType SMALL_STRIPES()
* @method static BannerPatternType SQUARE_BOTTOM_LEFT()
* @method static BannerPatternType SQUARE_BOTTOM_RIGHT()
* @method static BannerPatternType SQUARE_TOP_LEFT()
* @method static BannerPatternType SQUARE_TOP_RIGHT()
* @method static BannerPatternType STRAIGHT_CROSS()
* @method static BannerPatternType STRIPE_BOTTOM()
* @method static BannerPatternType STRIPE_CENTER()
* @method static BannerPatternType STRIPE_DOWNLEFT()
* @method static BannerPatternType STRIPE_DOWNRIGHT()
* @method static BannerPatternType STRIPE_LEFT()
* @method static BannerPatternType STRIPE_MIDDLE()
* @method static BannerPatternType STRIPE_RIGHT()
* @method static BannerPatternType STRIPE_TOP()
* @method static BannerPatternType TRIANGLES_BOTTOM()
* @method static BannerPatternType TRIANGLES_TOP()
* @method static BannerPatternType TRIANGLE_BOTTOM()
* @method static BannerPatternType TRIANGLE_TOP()
*/
enum BannerPatternType{
use LegacyEnumShimTrait;
case BORDER;
case BRICKS;
case CIRCLE;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BellAttachmentType CEILING()
* @method static BellAttachmentType FLOOR()
* @method static BellAttachmentType ONE_WALL()
* @method static BellAttachmentType TWO_WALLS()
*/
enum BellAttachmentType{
use LegacyEnumShimTrait;
case CEILING;
case FLOOR;
case ONE_WALL;

View File

@ -24,19 +24,8 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\inventory\BrewingStandInventory;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BrewingStandSlot EAST()
* @method static BrewingStandSlot NORTHWEST()
* @method static BrewingStandSlot SOUTHWEST()
*/
enum BrewingStandSlot{
use LegacyEnumShimTrait;
case EAST;
case NORTHWEST;
case SOUTHWEST;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static CopperOxidation EXPOSED()
* @method static CopperOxidation NONE()
* @method static CopperOxidation OXIDIZED()
* @method static CopperOxidation WEATHERED()
*/
enum CopperOxidation : int{
use LegacyEnumShimTrait;
case NONE = 0;
case EXPOSED = 1;
case WEATHERED = 2;

View File

@ -23,21 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static CoralType BRAIN()
* @method static CoralType BUBBLE()
* @method static CoralType FIRE()
* @method static CoralType HORN()
* @method static CoralType TUBE()
*/
enum CoralType{
use LegacyEnumShimTrait;
case TUBE;
case BRAIN;
case BUBBLE;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static DirtType COARSE()
* @method static DirtType NORMAL()
* @method static DirtType ROOTED()
*/
enum DirtType{
use LegacyEnumShimTrait;
case NORMAL;
case COARSE;
case ROOTED;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static DripleafState FULL_TILT()
* @method static DripleafState PARTIAL_TILT()
* @method static DripleafState STABLE()
* @method static DripleafState UNSTABLE()
*/
enum DripleafState{
use LegacyEnumShimTrait;
case STABLE;
case UNSTABLE;
case PARTIAL_TILT;

View File

@ -24,35 +24,12 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\color\Color;
use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static DyeColor BLACK()
* @method static DyeColor BLUE()
* @method static DyeColor BROWN()
* @method static DyeColor CYAN()
* @method static DyeColor GRAY()
* @method static DyeColor GREEN()
* @method static DyeColor LIGHT_BLUE()
* @method static DyeColor LIGHT_GRAY()
* @method static DyeColor LIME()
* @method static DyeColor MAGENTA()
* @method static DyeColor ORANGE()
* @method static DyeColor PINK()
* @method static DyeColor PURPLE()
* @method static DyeColor RED()
* @method static DyeColor WHITE()
* @method static DyeColor YELLOW()
*
* @phpstan-type TMetadata array{0: string, 1: Color}
*/
enum DyeColor{
use LegacyEnumShimTrait;
case WHITE;
case ORANGE;
case MAGENTA;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static FroglightType OCHRE()
* @method static FroglightType PEARLESCENT()
* @method static FroglightType VERDANT()
*/
enum FroglightType{
use LegacyEnumShimTrait;
case OCHRE;
case PEARLESCENT;
case VERDANT;

View File

@ -23,26 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static LeavesType ACACIA()
* @method static LeavesType AZALEA()
* @method static LeavesType BIRCH()
* @method static LeavesType CHERRY()
* @method static LeavesType DARK_OAK()
* @method static LeavesType FLOWERING_AZALEA()
* @method static LeavesType JUNGLE()
* @method static LeavesType MANGROVE()
* @method static LeavesType OAK()
* @method static LeavesType SPRUCE()
*/
enum LeavesType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -24,24 +24,8 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\math\Facing;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static LeverFacing DOWN_AXIS_X()
* @method static LeverFacing DOWN_AXIS_Z()
* @method static LeverFacing EAST()
* @method static LeverFacing NORTH()
* @method static LeverFacing SOUTH()
* @method static LeverFacing UP_AXIS_X()
* @method static LeverFacing UP_AXIS_Z()
* @method static LeverFacing WEST()
*/
enum LeverFacing{
use LegacyEnumShimTrait;
case UP_AXIS_X;
case UP_AXIS_Z;
case DOWN_AXIS_X;

View File

@ -23,23 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static MobHeadType CREEPER()
* @method static MobHeadType DRAGON()
* @method static MobHeadType PIGLIN()
* @method static MobHeadType PLAYER()
* @method static MobHeadType SKELETON()
* @method static MobHeadType WITHER_SKELETON()
* @method static MobHeadType ZOMBIE()
*/
enum MobHeadType{
use LegacyEnumShimTrait;
case SKELETON;
case WITHER_SKELETON;
case ZOMBIE;

View File

@ -23,27 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static MushroomBlockType ALL_CAP()
* @method static MushroomBlockType CAP_EAST()
* @method static MushroomBlockType CAP_MIDDLE()
* @method static MushroomBlockType CAP_NORTH()
* @method static MushroomBlockType CAP_NORTHEAST()
* @method static MushroomBlockType CAP_NORTHWEST()
* @method static MushroomBlockType CAP_SOUTH()
* @method static MushroomBlockType CAP_SOUTHEAST()
* @method static MushroomBlockType CAP_SOUTHWEST()
* @method static MushroomBlockType CAP_WEST()
* @method static MushroomBlockType PORES()
*/
enum MushroomBlockType{
use LegacyEnumShimTrait;
case PORES;
case CAP_NORTHWEST;
case CAP_NORTH;

View File

@ -26,34 +26,12 @@ namespace pocketmine\block\utils;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\lang\Translatable;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static RecordType DISK_11()
* @method static RecordType DISK_13()
* @method static RecordType DISK_5()
* @method static RecordType DISK_BLOCKS()
* @method static RecordType DISK_CAT()
* @method static RecordType DISK_CHIRP()
* @method static RecordType DISK_FAR()
* @method static RecordType DISK_MALL()
* @method static RecordType DISK_MELLOHI()
* @method static RecordType DISK_OTHERSIDE()
* @method static RecordType DISK_PIGSTEP()
* @method static RecordType DISK_STAL()
* @method static RecordType DISK_STRAD()
* @method static RecordType DISK_WAIT()
* @method static RecordType DISK_WARD()
*
* @phpstan-type TMetadata array{0: string, 1: LevelSoundEvent::*, 2: Translatable}
*/
enum RecordType{
use LegacyEnumShimTrait;
case DISK_13;
case DISK_5;
case DISK_CAT;

View File

@ -23,23 +23,9 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
use pocketmine\world\generator\object\TreeType;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SaplingType ACACIA()
* @method static SaplingType BIRCH()
* @method static SaplingType DARK_OAK()
* @method static SaplingType JUNGLE()
* @method static SaplingType OAK()
* @method static SaplingType SPRUCE()
*/
enum SaplingType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SlabType BOTTOM()
* @method static SlabType DOUBLE()
* @method static SlabType TOP()
*/
enum SlabType{
use LegacyEnumShimTrait;
case BOTTOM;
case TOP;
case DOUBLE;

View File

@ -23,21 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static StairShape INNER_LEFT()
* @method static StairShape INNER_RIGHT()
* @method static StairShape OUTER_LEFT()
* @method static StairShape OUTER_RIGHT()
* @method static StairShape STRAIGHT()
*/
enum StairShape{
use LegacyEnumShimTrait;
case STRAIGHT;
case INNER_LEFT;
case INNER_RIGHT;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SupportType CENTER()
* @method static SupportType EDGE()
* @method static SupportType FULL()
* @method static SupportType NONE()
*/
enum SupportType{
use LegacyEnumShimTrait;
case FULL;
case CENTER;
case EDGE;

View File

@ -23,18 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static WallConnectionType SHORT()
* @method static WallConnectionType TALL()
*/
enum WallConnectionType{
use LegacyEnumShimTrait;
case SHORT;
case TALL;
}

View File

@ -23,26 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static WoodType ACACIA()
* @method static WoodType BIRCH()
* @method static WoodType CHERRY()
* @method static WoodType CRIMSON()
* @method static WoodType DARK_OAK()
* @method static WoodType JUNGLE()
* @method static WoodType MANGROVE()
* @method static WoodType OAK()
* @method static WoodType SPRUCE()
* @method static WoodType WARPED()
*/
enum WoodType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\crafting;
use pocketmine\utils\LegacyEnumShimTrait;
use pocketmine\world\sound\BlastFurnaceSound;
use pocketmine\world\sound\FurnaceSound;
use pocketmine\world\sound\SmokerSound;
@ -31,18 +30,9 @@ use pocketmine\world\sound\Sound;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static FurnaceType BLAST_FURNACE()
* @method static FurnaceType FURNACE()
* @method static FurnaceType SMOKER()
*
* @phpstan-type TMetadata array{0: int, 1: Sound}
*/
enum FurnaceType{
use LegacyEnumShimTrait;
case FURNACE;
case BLAST_FURNACE;
case SMOKER;

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\crafting;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* 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()
*/
enum ShapelessRecipeType{
use LegacyEnumShimTrait;
case CRAFTING;
case STONECUTTER;
case SMITHING;

View File

@ -153,8 +153,7 @@ use pocketmine\block\WallBanner;
use pocketmine\block\WallCoralFan;
use pocketmine\block\WallSign;
use pocketmine\block\Water;
use pocketmine\block\WeightedPressurePlateHeavy;
use pocketmine\block\WeightedPressurePlateLight;
use pocketmine\block\WeightedPressurePlate;
use pocketmine\block\Wheat;
use pocketmine\block\Wood;
use pocketmine\block\WoodenButton;
@ -1608,11 +1607,11 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
return Writer::create(Ids::WEEPING_VINES)
->writeInt(StateNames::WEEPING_VINES_AGE, $block->getAge());
});
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlateHeavy $block) : Writer{
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlate $block) : Writer{
return Writer::create(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE)
->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength());
});
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), function(WeightedPressurePlateLight $block) : Writer{
$this->map(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), function(WeightedPressurePlate $block) : Writer{
return Writer::create(Ids::LIGHT_WEIGHTED_PRESSURE_PLATE)
->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength());
});

View File

@ -1,94 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\runtime;
/**
* Provides backwards-compatible shims for the old codegen'd enum describer methods.
* This is kept for plugin backwards compatibility, but these functions should not be used in new code.
* @deprecated
*/
trait LegacyRuntimeEnumDescriberTrait{
/**
* @phpstan-template T of \UnitEnum
* @phpstan-param T $case
*/
abstract protected function enum(\UnitEnum &$case) : void;
public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType &$value) : void{
$this->enum($value);
}
public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void{
$this->enum($value);
}
public function coralType(\pocketmine\block\utils\CoralType &$value) : void{
$this->enum($value);
}
public function dirtType(\pocketmine\block\utils\DirtType &$value) : void{
$this->enum($value);
}
public function dripleafState(\pocketmine\block\utils\DripleafState &$value) : void{
$this->enum($value);
}
public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void{
$this->enum($value);
}
public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void{
$this->enum($value);
}
public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void{
$this->enum($value);
}
public function medicineType(\pocketmine\item\MedicineType &$value) : void{
$this->enum($value);
}
public function mobHeadType(\pocketmine\block\utils\MobHeadType &$value) : void{
$this->enum($value);
}
public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void{
$this->enum($value);
}
public function potionType(\pocketmine\item\PotionType &$value) : void{
$this->enum($value);
}
public function slabType(\pocketmine\block\utils\SlabType &$value) : void{
$this->enum($value);
}
public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void{
$this->enum($value);
}
}

View File

@ -35,7 +35,7 @@ use pocketmine\math\Facing;
* You may use it as a type for parameters and return values, but it should not be implemented outside of this package.
* New methods may be added without warning.
*/
interface RuntimeDataDescriber extends RuntimeEnumDescriber{
interface RuntimeDataDescriber{
public function int(int $bits, int &$value) : void;
public function boundedInt(int $bits, int $min, int $max, int &$value) : void;

View File

@ -34,8 +34,6 @@ use function intdiv;
use function spl_object_id;
final class RuntimeDataReader implements RuntimeDataDescriber{
use LegacyRuntimeEnumDescriberTrait;
private int $offset = 0;
public function __construct(

View File

@ -28,8 +28,6 @@ use pocketmine\math\Facing;
use function count;
final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
use LegacyRuntimeEnumDescriberTrait;
private int $bits = 0;
protected function addBits(int $bits) : void{

View File

@ -31,8 +31,6 @@ use function array_flip;
use function spl_object_id;
final class RuntimeDataWriter implements RuntimeDataDescriber{
use LegacyRuntimeEnumDescriberTrait;
private int $value = 0;
private int $offset = 0;

View File

@ -1,61 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\runtime;
/**
* Provides backwards-compatible shims for the old codegen'd enum describer methods.
* This is kept for plugin backwards compatibility, but these functions should not be used in new code.
* @deprecated
*/
interface RuntimeEnumDescriber{
public function bellAttachmentType(\pocketmine\block\utils\BellAttachmentType &$value) : void;
public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void;
public function coralType(\pocketmine\block\utils\CoralType &$value) : void;
public function dirtType(\pocketmine\block\utils\DirtType &$value) : void;
public function dripleafState(\pocketmine\block\utils\DripleafState &$value) : void;
public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void;
public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void;
public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void;
public function medicineType(\pocketmine\item\MedicineType &$value) : void;
public function mobHeadType(\pocketmine\block\utils\MobHeadType &$value) : void;
public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void;
public function potionType(\pocketmine\item\PotionType &$value) : void;
public function slabType(\pocketmine\block\utils\SlabType &$value) : void;
public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void;
}

View File

@ -24,23 +24,8 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\utils\WoodType;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BoatType ACACIA()
* @method static BoatType BIRCH()
* @method static BoatType DARK_OAK()
* @method static BoatType JUNGLE()
* @method static BoatType MANGROVE()
* @method static BoatType OAK()
* @method static BoatType SPRUCE()
*/
enum BoatType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -23,19 +23,7 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static ItemUseResult FAIL()
* @method static ItemUseResult NONE()
* @method static ItemUseResult SUCCESS()
*/
enum ItemUseResult{
use LegacyEnumShimTrait;
case NONE;
case FAIL;
case SUCCESS;

View File

@ -25,20 +25,8 @@ namespace pocketmine\item;
use pocketmine\entity\effect\Effect;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static MedicineType ANTIDOTE()
* @method static MedicineType ELIXIR()
* @method static MedicineType EYE_DROPS()
* @method static MedicineType TONIC()
*/
enum MedicineType{
use LegacyEnumShimTrait;
case ANTIDOTE;
case ELIXIR;
case EYE_DROPS;

View File

@ -25,62 +25,12 @@ namespace pocketmine\item;
use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\utils\LegacyEnumShimTrait;
use function spl_object_id;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static PotionType AWKWARD()
* @method static PotionType FIRE_RESISTANCE()
* @method static PotionType HARMING()
* @method static PotionType HEALING()
* @method static PotionType INVISIBILITY()
* @method static PotionType LEAPING()
* @method static PotionType LONG_FIRE_RESISTANCE()
* @method static PotionType LONG_INVISIBILITY()
* @method static PotionType LONG_LEAPING()
* @method static PotionType LONG_MUNDANE()
* @method static PotionType LONG_NIGHT_VISION()
* @method static PotionType LONG_POISON()
* @method static PotionType LONG_REGENERATION()
* @method static PotionType LONG_SLOWNESS()
* @method static PotionType LONG_SLOW_FALLING()
* @method static PotionType LONG_STRENGTH()
* @method static PotionType LONG_SWIFTNESS()
* @method static PotionType LONG_TURTLE_MASTER()
* @method static PotionType LONG_WATER_BREATHING()
* @method static PotionType LONG_WEAKNESS()
* @method static PotionType MUNDANE()
* @method static PotionType NIGHT_VISION()
* @method static PotionType POISON()
* @method static PotionType REGENERATION()
* @method static PotionType SLOWNESS()
* @method static PotionType SLOW_FALLING()
* @method static PotionType STRENGTH()
* @method static PotionType STRONG_HARMING()
* @method static PotionType STRONG_HEALING()
* @method static PotionType STRONG_LEAPING()
* @method static PotionType STRONG_POISON()
* @method static PotionType STRONG_REGENERATION()
* @method static PotionType STRONG_SLOWNESS()
* @method static PotionType STRONG_STRENGTH()
* @method static PotionType STRONG_SWIFTNESS()
* @method static PotionType STRONG_TURTLE_MASTER()
* @method static PotionType SWIFTNESS()
* @method static PotionType THICK()
* @method static PotionType TURTLE_MASTER()
* @method static PotionType WATER()
* @method static PotionType WATER_BREATHING()
* @method static PotionType WEAKNESS()
* @method static PotionType WITHER()
*
* @phpstan-type TMetadata array{0: string, 1: \Closure() : list<EffectInstance>}
*/
enum PotionType{
use LegacyEnumShimTrait;
case WATER;
case MUNDANE;
case LONG_MUNDANE;

View File

@ -25,26 +25,8 @@ namespace pocketmine\item;
use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static SuspiciousStewType ALLIUM()
* @method static SuspiciousStewType AZURE_BLUET()
* @method static SuspiciousStewType BLUE_ORCHID()
* @method static SuspiciousStewType CORNFLOWER()
* @method static SuspiciousStewType DANDELION()
* @method static SuspiciousStewType LILY_OF_THE_VALLEY()
* @method static SuspiciousStewType OXEYE_DAISY()
* @method static SuspiciousStewType POPPY()
* @method static SuspiciousStewType TULIP()
* @method static SuspiciousStewType WITHER_ROSE()
*/
enum SuspiciousStewType{
use LegacyEnumShimTrait;
case POPPY;
case CORNFLOWER;
case TULIP;

View File

@ -23,26 +23,10 @@ declare(strict_types=1);
namespace pocketmine\item;
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
*
* @method static ToolTier DIAMOND()
* @method static ToolTier GOLD()
* @method static ToolTier IRON()
* @method static ToolTier NETHERITE()
* @method static ToolTier STONE()
* @method static ToolTier WOOD()
*
* @phpstan-type TMetadata array{0: int, 1: int, 2: int, 3: int, 4: int}
*/
enum ToolTier{
use LegacyEnumShimTrait;
case WOOD;
case GOLD;
case STONE;

View File

@ -44,15 +44,11 @@ class Enchantment{
/**
* @phpstan-param null|(\Closure(int $level) : int) $minEnchantingPower
*
* @param int $primaryItemFlags @deprecated
* @param int $secondaryItemFlags @deprecated
* @param int $enchantingPowerRange Value used to calculate the maximum enchanting power (minEnchantingPower + enchantingPowerRange)
*/
public function __construct(
private Translatable|string $name,
private int $rarity,
private int $primaryItemFlags,
private int $secondaryItemFlags,
private int $maxLevel,
?\Closure $minEnchantingPower = null,
private int $enchantingPowerRange = 50
@ -79,47 +75,6 @@ class Enchantment{
return $this->rarity;
}
/**
* Returns a bitset indicating what item types can have this item applied from an enchanting table.
*
* @deprecated
* @see AvailableEnchantmentRegistry::getPrimaryItemTags()
*/
public function getPrimaryItemFlags() : int{
return $this->primaryItemFlags;
}
/**
* Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from
* an anvil.
*
* @deprecated
* @see AvailableEnchantmentRegistry::getSecondaryItemTags()
*/
public function getSecondaryItemFlags() : int{
return $this->secondaryItemFlags;
}
/**
* Returns whether this enchantment can apply to the item type from an enchanting table.
*
* @deprecated
* @see AvailableEnchantmentRegistry
*/
public function hasPrimaryItemType(int $flag) : bool{
return ($this->primaryItemFlags & $flag) !== 0;
}
/**
* Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.
*
* @deprecated
* @see AvailableEnchantmentRegistry
*/
public function hasSecondaryItemType(int $flag) : bool{
return ($this->secondaryItemFlags & $flag) !== 0;
}
/**
* Returns the maximum level of this enchantment that can be found on an enchantment table.
*/

View File

@ -1,54 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item\enchantment;
/** @deprecated */
final class ItemFlags{
private function __construct(){
//NOOP
}
public const NONE = 0x0;
public const ALL = 0xffff;
public const ARMOR = self::HEAD | self::TORSO | self::LEGS | self::FEET;
public const HEAD = 0x1;
public const TORSO = 0x2;
public const LEGS = 0x4;
public const FEET = 0x8;
public const SWORD = 0x10;
public const BOW = 0x20;
public const TOOL = self::HOE | self::SHEARS | self::FLINT_AND_STEEL;
public const HOE = 0x40;
public const SHEARS = 0x80;
public const FLINT_AND_STEEL = 0x100;
public const DIG = self::AXE | self::PICKAXE | self::SHOVEL;
public const AXE = 0x200;
public const PICKAXE = 0x400;
public const SHOVEL = 0x800;
public const FISHING_ROD = 0x1000;
public const CARROT_STICK = 0x2000;
public const ELYTRA = 0x4000;
public const TRIDENT = 0x8000;
}

View File

@ -38,13 +38,11 @@ class ProtectionEnchantment extends Enchantment{
*
* @phpstan-param null|(\Closure(int $level) : int) $minEnchantingPower
*
* @param int $primaryItemFlags @deprecated
* @param int $secondaryItemFlags @deprecated
* @param int[]|null $applicableDamageTypes EntityDamageEvent::CAUSE_* constants which this enchantment type applies to, or null if it applies to all types of damage.
* @param int $enchantingPowerRange Value used to calculate the maximum enchanting power (minEnchantingPower + enchantingPowerRange)
*/
public function __construct(Translatable|string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes, ?\Closure $minEnchantingPower = null, int $enchantingPowerRange = 50){
parent::__construct($name, $rarity, $primaryItemFlags, $secondaryItemFlags, $maxLevel, $minEnchantingPower, $enchantingPowerRange);
public function __construct(Translatable|string $name, int $rarity, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes, ?\Closure $minEnchantingPower = null, int $enchantingPowerRange = 50){
parent::__construct($name, $rarity, $maxLevel, $minEnchantingPower, $enchantingPowerRange);
$this->typeModifier = $typeModifier;
if($applicableDamageTypes !== null){

View File

@ -62,8 +62,6 @@ final class VanillaEnchantments{
self::register("PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_all(),
Rarity::COMMON,
0,
0,
4,
0.75,
null,
@ -73,8 +71,6 @@ final class VanillaEnchantments{
self::register("FIRE_PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_fire(),
Rarity::UNCOMMON,
0,
0,
4,
1.25,
[
@ -89,8 +85,6 @@ final class VanillaEnchantments{
self::register("FEATHER_FALLING", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_fall(),
Rarity::UNCOMMON,
0,
0,
4,
2.5,
[
@ -102,8 +96,6 @@ final class VanillaEnchantments{
self::register("BLAST_PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_explosion(),
Rarity::RARE,
0,
0,
4,
1.5,
[
@ -116,8 +108,6 @@ final class VanillaEnchantments{
self::register("PROJECTILE_PROTECTION", new ProtectionEnchantment(
KnownTranslationFactory::enchantment_protect_projectile(),
Rarity::UNCOMMON,
0,
0,
4,
1.5,
[
@ -129,8 +119,6 @@ final class VanillaEnchantments{
self::register("THORNS", new Enchantment(
KnownTranslationFactory::enchantment_thorns(),
Rarity::MYTHIC,
0,
0,
3,
fn(int $level) : int => 20 * ($level - 1) + 10,
50
@ -138,8 +126,6 @@ final class VanillaEnchantments{
self::register("RESPIRATION", new Enchantment(
KnownTranslationFactory::enchantment_oxygen(),
Rarity::RARE,
0,
0,
3,
fn(int $level) : int => 10 * $level,
30
@ -148,8 +134,6 @@ final class VanillaEnchantments{
self::register("SHARPNESS", new SharpnessEnchantment(
KnownTranslationFactory::enchantment_damage_all(),
Rarity::COMMON,
0,
0,
5,
fn(int $level) : int => 11 * ($level - 1) + 1,
20
@ -157,8 +141,6 @@ final class VanillaEnchantments{
self::register("KNOCKBACK", new KnockbackEnchantment(
KnownTranslationFactory::enchantment_knockback(),
Rarity::UNCOMMON,
0,
0,
2,
fn(int $level) : int => 20 * ($level - 1) + 5,
50
@ -166,8 +148,6 @@ final class VanillaEnchantments{
self::register("FIRE_ASPECT", new FireAspectEnchantment(
KnownTranslationFactory::enchantment_fire(),
Rarity::RARE,
0,
0,
2,
fn(int $level) : int => 20 * ($level - 1) + 10,
50
@ -177,8 +157,6 @@ final class VanillaEnchantments{
self::register("EFFICIENCY", new Enchantment(
KnownTranslationFactory::enchantment_digging(),
Rarity::COMMON,
0,
0,
5,
fn(int $level) : int => 10 * ($level - 1) + 1,
50
@ -186,8 +164,6 @@ final class VanillaEnchantments{
self::register("FORTUNE", new Enchantment(
KnownTranslationFactory::enchantment_lootBonusDigger(),
Rarity::RARE,
0,
0,
3,
fn(int $level) : int => 9 * ($level - 1) + 15,
50
@ -195,8 +171,6 @@ final class VanillaEnchantments{
self::register("SILK_TOUCH", new Enchantment(
KnownTranslationFactory::enchantment_untouching(),
Rarity::MYTHIC,
0,
0,
1,
fn(int $level) : int => 15,
50
@ -204,8 +178,6 @@ final class VanillaEnchantments{
self::register("UNBREAKING", new Enchantment(
KnownTranslationFactory::enchantment_durability(),
Rarity::UNCOMMON,
0,
0,
3,
fn(int $level) : int => 8 * ($level - 1) + 5,
50
@ -214,8 +186,6 @@ final class VanillaEnchantments{
self::register("POWER", new Enchantment(
KnownTranslationFactory::enchantment_arrowDamage(),
Rarity::COMMON,
0,
0,
5,
fn(int $level) : int => 10 * ($level - 1) + 1,
15
@ -223,8 +193,6 @@ final class VanillaEnchantments{
self::register("PUNCH", new Enchantment(
KnownTranslationFactory::enchantment_arrowKnockback(),
Rarity::RARE,
0,
0,
2,
fn(int $level) : int => 20 * ($level - 1) + 12,
25
@ -232,8 +200,6 @@ final class VanillaEnchantments{
self::register("FLAME", new Enchantment(
KnownTranslationFactory::enchantment_arrowFire(),
Rarity::RARE,
0,
0,
1,
fn(int $level) : int => 20,
30
@ -241,8 +207,6 @@ final class VanillaEnchantments{
self::register("INFINITY", new Enchantment(
KnownTranslationFactory::enchantment_arrowInfinite(),
Rarity::MYTHIC,
0,
0,
1,
fn(int $level) : int => 20,
30
@ -251,8 +215,6 @@ final class VanillaEnchantments{
self::register("MENDING", new Enchantment(
KnownTranslationFactory::enchantment_mending(),
Rarity::RARE,
0,
0,
1,
fn(int $level) : int => 25,
50
@ -261,8 +223,6 @@ final class VanillaEnchantments{
self::register("VANISHING", new Enchantment(
KnownTranslationFactory::enchantment_curse_vanishing(),
Rarity::MYTHIC,
0,
0,
1,
fn(int $level) : int => 25,
25
@ -271,8 +231,6 @@ final class VanillaEnchantments{
self::register("SWIFT_SNEAK", new Enchantment(
KnownTranslationFactory::enchantment_swift_sneak(),
Rarity::MYTHIC,
0,
0,
3,
fn(int $level) : int => 10 * $level,
5

View File

@ -23,20 +23,7 @@ declare(strict_types=1);
namespace pocketmine\player;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static UsedChunkStatus NEEDED()
* @method static UsedChunkStatus REQUESTED_GENERATION()
* @method static UsedChunkStatus REQUESTED_SENDING()
* @method static UsedChunkStatus SENT()
*/
enum UsedChunkStatus{
use LegacyEnumShimTrait;
case NEEDED;
case REQUESTED_GENERATION;
case REQUESTED_SENDING;

View File

@ -30,8 +30,7 @@ namespace pocketmine\utils;
* Classes using this trait need to include \@method tags in their class docblock for every enum member.
* Alternatively, just put \@generate-registry-docblock in the docblock and run tools/generate-registry-annotations.php
*
* @deprecated Use native PHP 8.1 enums instead. Use {@link LegacyEnumShimTrait} if you need to provide backwards
* compatible EnumTrait-like API for migrated enums.
* @deprecated Use native PHP 8.1 enums instead.
*/
trait EnumTrait{
use RegistryTrait;

View File

@ -1,92 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\utils;
use function count;
use function mb_strtoupper;
use function spl_object_id;
/**
* Offers a shim to make a native enum behave similarly to a legacy {@link EnumTrait} enum.
* Used to provide backwards compatibility for enums that have been migrated to native PHP 8.1 enums.
*
* @deprecated
*/
trait LegacyEnumShimTrait{
/**
* @param mixed[] $arguments
*/
public static function __callStatic(string $name, array $arguments) : self{
if(count($arguments) > 0){
throw new \ArgumentCountError("Expected exactly 0 arguments, " . count($arguments) . " passed");
}
return self::getAll()[mb_strtoupper($name)];
}
/**
* Returns a list of all cases, indexed by name.
*
* @return self[]
* @phpstan-return array<string, self>
*/
public static function getAll() : array{
/** @var array<string, self>|null $result */
static $result = null;
if($result === null){
$result = [];
foreach(self::cases() as $case){
$result[mb_strtoupper($case->name)] = $case;
}
}
return $result;
}
/**
* Shim for {@link \UnitEnum::name}.
*
* @deprecated Use the native enum's name property instead.
*/
public function name() : string{
return $this->name;
}
/**
* Alias of spl_object_id($this).
*
* @deprecated
*/
public function id() : int{
return spl_object_id($this);
}
/**
* Returns whether the two objects are equivalent.
*
* @deprecated Native enums can be safely compared with ===.
*/
public function equals(self $other) : bool{
return $this === $other;
}
}

View File

@ -23,22 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static TreeType ACACIA()
* @method static TreeType BIRCH()
* @method static TreeType DARK_OAK()
* @method static TreeType JUNGLE()
* @method static TreeType OAK()
* @method static TreeType SPRUCE()
*/
enum TreeType{
use LegacyEnumShimTrait;
case OAK;
case SPRUCE;
case BIRCH;

View File

@ -23,32 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\sound;
use pocketmine\utils\LegacyEnumShimTrait;
/**
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static NoteInstrument BANJO()
* @method static NoteInstrument BASS_DRUM()
* @method static NoteInstrument BELL()
* @method static NoteInstrument BIT()
* @method static NoteInstrument CHIME()
* @method static NoteInstrument CLICKS_AND_STICKS()
* @method static NoteInstrument COW_BELL()
* @method static NoteInstrument DIDGERIDOO()
* @method static NoteInstrument DOUBLE_BASS()
* @method static NoteInstrument FLUTE()
* @method static NoteInstrument GUITAR()
* @method static NoteInstrument IRON_XYLOPHONE()
* @method static NoteInstrument PIANO()
* @method static NoteInstrument PLING()
* @method static NoteInstrument SNARE()
* @method static NoteInstrument XYLOPHONE()
*/
enum NoteInstrument{
use LegacyEnumShimTrait;
case PIANO;
case BASS_DRUM;
case SNARE;