mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 12:55:21 +00:00
Enchantment: apply typehints to PHP 7.2 standards
This commit is contained in:
parent
fbf760bafe
commit
164ce76ff5
@ -93,7 +93,7 @@ class Enchantment{
|
|||||||
/** @var Enchantment[] */
|
/** @var Enchantment[] */
|
||||||
protected static $enchantments;
|
protected static $enchantments;
|
||||||
|
|
||||||
public static function init(){
|
public static function init() : void{
|
||||||
self::$enchantments = new \SplFixedArray(256);
|
self::$enchantments = new \SplFixedArray(256);
|
||||||
|
|
||||||
self::registerEnchantment(new ProtectionEnchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 0.75, null));
|
self::registerEnchantment(new ProtectionEnchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 0.75, null));
|
||||||
@ -137,7 +137,7 @@ class Enchantment{
|
|||||||
*
|
*
|
||||||
* @return Enchantment|null
|
* @return Enchantment|null
|
||||||
*/
|
*/
|
||||||
public static function getEnchantment(int $id){
|
public static function getEnchantment(int $id) : ?Enchantment{
|
||||||
return self::$enchantments[$id] ?? null;
|
return self::$enchantments[$id] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ class Enchantment{
|
|||||||
*
|
*
|
||||||
* @return Enchantment|null
|
* @return Enchantment|null
|
||||||
*/
|
*/
|
||||||
public static function getEnchantmentByName(string $name){
|
public static function getEnchantmentByName(string $name) : ?Enchantment{
|
||||||
$const = Enchantment::class . "::" . strtoupper($name);
|
$const = Enchantment::class . "::" . strtoupper($name);
|
||||||
if(defined($const)){
|
if(defined($const)){
|
||||||
return self::getEnchantment(constant($const));
|
return self::getEnchantment(constant($const));
|
||||||
|
@ -28,29 +28,31 @@ class EnchantmentEntry{
|
|||||||
|
|
||||||
/** @var Enchantment[] */
|
/** @var Enchantment[] */
|
||||||
private $enchantments;
|
private $enchantments;
|
||||||
|
/** @var int */
|
||||||
private $cost;
|
private $cost;
|
||||||
|
/** @var string */
|
||||||
private $randomName;
|
private $randomName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Enchantment[] $enchantments
|
* @param Enchantment[] $enchantments
|
||||||
* @param number $cost
|
* @param int $cost
|
||||||
* @param string $randomName
|
* @param string $randomName
|
||||||
*/
|
*/
|
||||||
public function __construct(array $enchantments, $cost, $randomName){
|
public function __construct(array $enchantments, int $cost, string $randomName){
|
||||||
$this->enchantments = $enchantments;
|
$this->enchantments = $enchantments;
|
||||||
$this->cost = (int) $cost;
|
$this->cost = $cost;
|
||||||
$this->randomName = $randomName;
|
$this->randomName = $randomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEnchantments(){
|
public function getEnchantments() : array{
|
||||||
return $this->enchantments;
|
return $this->enchantments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost(){
|
public function getCost() : int{
|
||||||
return $this->cost;
|
return $this->cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRandomName(){
|
public function getRandomName() : string{
|
||||||
return $this->randomName;
|
return $this->randomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,30 +26,31 @@ namespace pocketmine\item\enchantment;
|
|||||||
|
|
||||||
class EnchantmentList{
|
class EnchantmentList{
|
||||||
|
|
||||||
/** @var EnchantmentEntry[] */
|
/** @var \SplFixedArray|EnchantmentEntry[] */
|
||||||
private $enchantments;
|
private $enchantments;
|
||||||
|
|
||||||
public function __construct($size){
|
public function __construct(int $size){
|
||||||
$this->enchantments = new \SplFixedArray($size);
|
$this->enchantments = new \SplFixedArray($size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $slot
|
* @param int $slot
|
||||||
* @param EnchantmentEntry $entry
|
* @param EnchantmentEntry $entry
|
||||||
*/
|
*/
|
||||||
public function setSlot($slot, EnchantmentEntry $entry){
|
public function setSlot(int $slot, EnchantmentEntry $entry) : void{
|
||||||
$this->enchantments[$slot] = $entry;
|
$this->enchantments[$slot] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $slot
|
* @param int $slot
|
||||||
|
*
|
||||||
* @return EnchantmentEntry
|
* @return EnchantmentEntry
|
||||||
*/
|
*/
|
||||||
public function getSlot($slot){
|
public function getSlot(int $slot) : EnchantmentEntry{
|
||||||
return $this->enchantments[$slot];
|
return $this->enchantments[$slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(){
|
public function getSize() : int{
|
||||||
return $this->enchantments->getSize();
|
return $this->enchantments->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user