mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Modernize private property declarations in src/item
This commit is contained in:
parent
fb4d332d1a
commit
95ad3f16e1
@ -40,8 +40,7 @@ class Armor extends Durable{
|
||||
|
||||
public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int
|
||||
|
||||
/** @var ArmorTypeInfo */
|
||||
private $armorInfo;
|
||||
private ArmorTypeInfo $armorInfo;
|
||||
|
||||
/** @var Color|null */
|
||||
protected $customColor = null;
|
||||
|
@ -24,19 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
class ArmorTypeInfo{
|
||||
|
||||
/** @var int */
|
||||
private $defensePoints;
|
||||
/** @var int */
|
||||
private $maxDurability;
|
||||
/** @var int */
|
||||
private $armorSlot;
|
||||
|
||||
public function __construct(int $defensePoints, int $maxDurability, int $armorSlot){
|
||||
$this->defensePoints = $defensePoints;
|
||||
$this->maxDurability = $maxDurability;
|
||||
$this->armorSlot = $armorSlot;
|
||||
}
|
||||
public function __construct(
|
||||
private int $defensePoints,
|
||||
private int $maxDurability,
|
||||
private int $armorSlot
|
||||
){}
|
||||
|
||||
public function getDefensePoints() : int{
|
||||
return $this->defensePoints;
|
||||
|
@ -39,14 +39,13 @@ class Banner extends ItemBlockWallOrFloor{
|
||||
public const TAG_PATTERN_COLOR = TileBanner::TAG_PATTERN_COLOR;
|
||||
public const TAG_PATTERN_NAME = TileBanner::TAG_PATTERN_NAME;
|
||||
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
private DyeColor $color;
|
||||
|
||||
/**
|
||||
* @var BannerPatternLayer[]
|
||||
* @phpstan-var list<BannerPatternLayer>
|
||||
*/
|
||||
private $patterns = [];
|
||||
private array $patterns = [];
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, Block $floorVariant, Block $wallVariant){
|
||||
parent::__construct($identifier, $floorVariant, $wallVariant);
|
||||
|
@ -28,9 +28,7 @@ use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Bed extends Item{
|
||||
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
private DyeColor $color;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, DyeColor $color){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -26,8 +26,7 @@ namespace pocketmine\item;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
|
||||
class Boat extends Item{
|
||||
/** @var TreeType */
|
||||
private $woodType;
|
||||
private TreeType $woodType;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, TreeType $woodType){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -32,8 +32,7 @@ abstract class Durable extends Item{
|
||||
|
||||
/** @var int */
|
||||
protected $damage = 0;
|
||||
/** @var bool */
|
||||
private $unbreakable = false;
|
||||
private bool $unbreakable = false;
|
||||
|
||||
public function getMeta() : int{
|
||||
return $this->damage;
|
||||
|
@ -26,9 +26,7 @@ namespace pocketmine\item;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
|
||||
class Dye extends Item{
|
||||
|
||||
/** @var DyeColor */
|
||||
private $color;
|
||||
private DyeColor $color;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, DyeColor $color){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -65,10 +65,9 @@ class Item implements \JsonSerializable{
|
||||
public const TAG_DISPLAY_NAME = "Name";
|
||||
public const TAG_DISPLAY_LORE = "Lore";
|
||||
|
||||
/** @var ItemIdentifier */
|
||||
private $identifier;
|
||||
/** @var CompoundTag */
|
||||
private $nbt;
|
||||
private ItemIdentifier $identifier;
|
||||
private CompoundTag $nbt;
|
||||
|
||||
/** @var int */
|
||||
protected $count = 1;
|
||||
/** @var string */
|
||||
|
@ -30,8 +30,7 @@ use pocketmine\block\BlockFactory;
|
||||
* Class used for Items that can be Blocks
|
||||
*/
|
||||
class ItemBlock extends Item{
|
||||
/** @var int */
|
||||
private $blockFullId;
|
||||
private int $blockFullId;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, Block $block){
|
||||
parent::__construct($identifier, $block->getName());
|
||||
|
@ -29,11 +29,8 @@ use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class ItemBlockWallOrFloor extends Item{
|
||||
|
||||
/** @var int */
|
||||
private $floorVariant;
|
||||
/** @var int */
|
||||
private $wallVariant;
|
||||
private int $floorVariant;
|
||||
private int $wallVariant;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, Block $floorVariant, Block $wallVariant){
|
||||
parent::__construct($identifier, $floorVariant->getName());
|
||||
|
@ -55,7 +55,7 @@ class ItemFactory{
|
||||
use SingletonTrait;
|
||||
|
||||
/** @var Item[] */
|
||||
private $list = [];
|
||||
private array $list = [];
|
||||
|
||||
public function __construct(){
|
||||
$this->registerArmorItems();
|
||||
|
@ -24,11 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
final class ItemIdentifier{
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
/** @var int */
|
||||
private $meta;
|
||||
private int $id;
|
||||
private int $meta;
|
||||
|
||||
public function __construct(int $id, int $meta){
|
||||
if($id < -0x8000 || $id > 0x7fff){ //signed short range
|
||||
|
@ -50,9 +50,6 @@ use function trim;
|
||||
final class LegacyStringToItemParser{
|
||||
use SingletonTrait;
|
||||
|
||||
/** @var ItemFactory */
|
||||
private $itemFactory;
|
||||
|
||||
private static function make() : self{
|
||||
$result = new self(ItemFactory::getInstance());
|
||||
|
||||
@ -73,11 +70,9 @@ final class LegacyStringToItemParser{
|
||||
* @var int[]
|
||||
* @phpstan-var array<string, int>
|
||||
*/
|
||||
private $map = [];
|
||||
private array $map = [];
|
||||
|
||||
public function __construct(ItemFactory $itemFactory){
|
||||
$this->itemFactory = $itemFactory;
|
||||
}
|
||||
public function __construct(private ItemFactory $itemFactory){}
|
||||
|
||||
public function addMapping(string $alias, int $id) : void{
|
||||
$this->map[$alias] = $id;
|
||||
|
@ -31,9 +31,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class LiquidBucket extends Item{
|
||||
|
||||
/** @var Liquid */
|
||||
private $liquid;
|
||||
private Liquid $liquid;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, Liquid $liquid){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -26,9 +26,9 @@ namespace pocketmine\item;
|
||||
use pocketmine\block\utils\RecordType;
|
||||
|
||||
class Record extends Item{
|
||||
/** @var RecordType */
|
||||
private $recordType;
|
||||
private RecordType $recordType;
|
||||
|
||||
//TODO: inconsistent parameter order
|
||||
public function __construct(ItemIdentifier $identifier, RecordType $recordType, string $name){
|
||||
$this->recordType = $recordType;
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -28,9 +28,7 @@ use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Skull extends Item{
|
||||
|
||||
/** @var SkullType */
|
||||
private $skullType;
|
||||
private SkullType $skullType;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name, SkullType $skullType){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -52,21 +52,14 @@ final class ToolTier{
|
||||
);
|
||||
}
|
||||
|
||||
/** @var int */
|
||||
private $harvestLevel;
|
||||
/** @var int */
|
||||
private $maxDurability;
|
||||
/** @var int */
|
||||
private $baseAttackPoints;
|
||||
/** @var int */
|
||||
private $baseEfficiency;
|
||||
|
||||
private function __construct(string $name, int $harvestLevel, int $maxDurability, int $baseAttackPoints, int $baseEfficiency){
|
||||
private function __construct(
|
||||
string $name,
|
||||
private int $harvestLevel,
|
||||
private int $maxDurability,
|
||||
private int $baseAttackPoints,
|
||||
private int $baseEfficiency
|
||||
){
|
||||
$this->Enum___construct($name);
|
||||
$this->harvestLevel = $harvestLevel;
|
||||
$this->maxDurability = $maxDurability;
|
||||
$this->baseAttackPoints = $baseAttackPoints;
|
||||
$this->baseEfficiency = $baseEfficiency;
|
||||
}
|
||||
|
||||
public function getHarvestLevel() : int{
|
||||
|
@ -42,7 +42,7 @@ abstract class WritableBookBase extends Item{
|
||||
* @var WritableBookPage[]
|
||||
* @phpstan-var list<WritableBookPage>
|
||||
*/
|
||||
private $pages = [];
|
||||
private array $pages = [];
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, string $name){
|
||||
parent::__construct($identifier, $name);
|
||||
|
@ -32,10 +32,8 @@ class WritableBookPage{
|
||||
public const PAGE_LENGTH_HARD_LIMIT_BYTES = Limits::INT16_MAX;
|
||||
public const PHOTO_NAME_LENGTH_HARD_LIMIT_BYTES = Limits::INT16_MAX;
|
||||
|
||||
/** @var string */
|
||||
private $text;
|
||||
/** @var string */
|
||||
private $photoName;
|
||||
private string $text;
|
||||
private string $photoName;
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
|
@ -40,12 +40,9 @@ class WrittenBook extends WritableBookBase{
|
||||
public const TAG_AUTHOR = "author"; //TAG_String
|
||||
public const TAG_TITLE = "title"; //TAG_String
|
||||
|
||||
/** @var int */
|
||||
private $generation = self::GENERATION_ORIGINAL;
|
||||
/** @var string */
|
||||
private $author = "";
|
||||
/** @var string */
|
||||
private $title = "";
|
||||
private int $generation = self::GENERATION_ORIGINAL;
|
||||
private string $author = "";
|
||||
private string $title = "";
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
|
@ -29,21 +29,10 @@ namespace pocketmine\item\enchantment;
|
||||
* Note: This class is assumed to be immutable. Consider this before making alterations.
|
||||
*/
|
||||
final class EnchantmentInstance{
|
||||
/** @var Enchantment */
|
||||
private $enchantment;
|
||||
/** @var int */
|
||||
private $level;
|
||||
|
||||
/**
|
||||
* EnchantmentInstance constructor.
|
||||
*
|
||||
* @param Enchantment $enchantment Enchantment type
|
||||
* @param int $level Level of enchantment
|
||||
*/
|
||||
public function __construct(Enchantment $enchantment, int $level = 1){
|
||||
$this->enchantment = $enchantment;
|
||||
$this->level = $level;
|
||||
}
|
||||
public function __construct(
|
||||
private Enchantment $enchantment,
|
||||
private int $level = 1
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the type of this enchantment.
|
||||
|
Loading…
x
Reference in New Issue
Block a user