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

@ -34,6 +34,7 @@ use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use function array_key_exists;
use function spl_object_id;
class BrewingStand extends Transparent{
@ -61,18 +62,18 @@ class BrewingStand extends Transparent{
}
public function getSupportType(int $facing) : SupportType{
return SupportType::NONE();
return SupportType::NONE;
}
public function hasSlot(BrewingStandSlot $slot) : bool{
return array_key_exists($slot->id(), $this->slots);
return array_key_exists(spl_object_id($slot), $this->slots);
}
public function setSlot(BrewingStandSlot $slot, bool $occupied) : self{
if($occupied){
$this->slots[$slot->id()] = $slot;
$this->slots[spl_object_id($slot)] = $slot;
}else{
unset($this->slots[$slot->id()]);
unset($this->slots[spl_object_id($slot)]);
}
return $this;
}
@ -89,7 +90,7 @@ class BrewingStand extends Transparent{
public function setSlots(array $slots) : self{
$this->slots = [];
foreach($slots as $slot){
$this->slots[$slot->id()] = $slot;
$this->slots[spl_object_id($slot)] = $slot;
}
return $this;
}
@ -114,7 +115,7 @@ class BrewingStand extends Transparent{
}
$changed = false;
foreach(BrewingStandSlot::getAll() as $slot){
foreach(BrewingStandSlot::cases() as $slot){
$occupied = !$brewing->getInventory()->isSlotEmpty($slot->getSlotNumber());
if($occupied !== $this->hasSlot($slot)){
$this->setSlot($slot, $occupied);