Unnecessary ":?" (2)

This commit is contained in:
Sunch 2024-08-17 20:08:11 +08:00
parent 0f26e45638
commit 69385e16f2
21 changed files with 36 additions and 48 deletions

View file

@ -413,11 +413,7 @@ class Player{
* @return Item
*/
public function getSlot($slot){
if(isset($this->inventory[(int) $slot])){
return $this->inventory[(int) $slot];
}else{
return BlockAPI::getItem(AIR, 0, 0);
}
return $this->inventory[(int)$slot] ?? BlockAPI::getItem(AIR, 0, 0);
}
/**
@ -724,11 +720,7 @@ class Player{
* @return Item
*/
public function getArmor($slot){
if(isset($this->armor[(int) $slot])){
return $this->armor[(int) $slot];
}else{
return BlockAPI::getItem(AIR, 0, 0);
}
return $this->armor[(int)$slot] ?? BlockAPI::getItem(AIR, 0, 0);
}
public function setArmor($slot, Item $armor, $send = true){
@ -779,7 +771,7 @@ class Player{
if($w === $data["tile"]){
$pk = new ContainerSetSlotPacket;
$pk->windowid = $id;
$pk->slot = $data["slot"] + (isset($data["offset"]) ? $data["offset"] : 0);
$pk->slot = $data["slot"] + ($data["offset"] ?? 0);
$pk->item = $data["slotdata"];
$this->dataPacket($pk);
}
@ -1729,7 +1721,7 @@ class Player{
$pos = new Position($this->entity->x, $this->entity->y, $this->entity->z, $this->level);
$pData = $this->data->get("position");
$this->teleport($pos, isset($pData["yaw"]) ? $pData["yaw"] : false, isset($pData["pitch"]) ? $pData["pitch"] : false, true, true);
$this->teleport($pos, $pData["yaw"] ?? false, $pData["pitch"] ?? false, true, true);
$this->entity->setHealth($this->data->get("health"), "spawn", true);
$this->spawned = true;
$this->server->api->player->spawnAllPlayers($this);