mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +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[] */
|
||||
protected static $enchantments;
|
||||
|
||||
public static function init(){
|
||||
public static function init() : void{
|
||||
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));
|
||||
@ -137,7 +137,7 @@ class Enchantment{
|
||||
*
|
||||
* @return Enchantment|null
|
||||
*/
|
||||
public static function getEnchantment(int $id){
|
||||
public static function getEnchantment(int $id) : ?Enchantment{
|
||||
return self::$enchantments[$id] ?? null;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class Enchantment{
|
||||
*
|
||||
* @return Enchantment|null
|
||||
*/
|
||||
public static function getEnchantmentByName(string $name){
|
||||
public static function getEnchantmentByName(string $name) : ?Enchantment{
|
||||
$const = Enchantment::class . "::" . strtoupper($name);
|
||||
if(defined($const)){
|
||||
return self::getEnchantment(constant($const));
|
||||
|
@ -28,29 +28,31 @@ class EnchantmentEntry{
|
||||
|
||||
/** @var Enchantment[] */
|
||||
private $enchantments;
|
||||
/** @var int */
|
||||
private $cost;
|
||||
/** @var string */
|
||||
private $randomName;
|
||||
|
||||
/**
|
||||
* @param Enchantment[] $enchantments
|
||||
* @param number $cost
|
||||
* @param int $cost
|
||||
* @param string $randomName
|
||||
*/
|
||||
public function __construct(array $enchantments, $cost, $randomName){
|
||||
public function __construct(array $enchantments, int $cost, string $randomName){
|
||||
$this->enchantments = $enchantments;
|
||||
$this->cost = (int) $cost;
|
||||
$this->cost = $cost;
|
||||
$this->randomName = $randomName;
|
||||
}
|
||||
|
||||
public function getEnchantments(){
|
||||
public function getEnchantments() : array{
|
||||
return $this->enchantments;
|
||||
}
|
||||
|
||||
public function getCost(){
|
||||
public function getCost() : int{
|
||||
return $this->cost;
|
||||
}
|
||||
|
||||
public function getRandomName(){
|
||||
public function getRandomName() : string{
|
||||
return $this->randomName;
|
||||
}
|
||||
|
||||
|
@ -26,30 +26,31 @@ namespace pocketmine\item\enchantment;
|
||||
|
||||
class EnchantmentList{
|
||||
|
||||
/** @var EnchantmentEntry[] */
|
||||
/** @var \SplFixedArray|EnchantmentEntry[] */
|
||||
private $enchantments;
|
||||
|
||||
public function __construct($size){
|
||||
public function __construct(int $size){
|
||||
$this->enchantments = new \SplFixedArray($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $slot
|
||||
* @param int $slot
|
||||
* @param EnchantmentEntry $entry
|
||||
*/
|
||||
public function setSlot($slot, EnchantmentEntry $entry){
|
||||
public function setSlot(int $slot, EnchantmentEntry $entry) : void{
|
||||
$this->enchantments[$slot] = $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $slot
|
||||
* @param int $slot
|
||||
*
|
||||
* @return EnchantmentEntry
|
||||
*/
|
||||
public function getSlot($slot){
|
||||
public function getSlot(int $slot) : EnchantmentEntry{
|
||||
return $this->enchantments[$slot];
|
||||
}
|
||||
|
||||
public function getSize(){
|
||||
public function getSize() : int{
|
||||
return $this->enchantments->getSize();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user