mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Player: Don't rely on magic numbers for gamemodes
This commit is contained in:
parent
31336a0d09
commit
ba616ed8a7
@ -1379,11 +1379,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isSurvival(bool $literal = false) : bool{
|
public function isSurvival(bool $literal = false) : bool{
|
||||||
if($literal){
|
return $this->gamemode === GameMode::SURVIVAL or (!$literal and $this->gamemode === GameMode::ADVENTURE);
|
||||||
return $this->gamemode === GameMode::SURVIVAL;
|
|
||||||
}else{
|
|
||||||
return ($this->gamemode & 0x01) === 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1395,11 +1391,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isCreative(bool $literal = false) : bool{
|
public function isCreative(bool $literal = false) : bool{
|
||||||
if($literal){
|
return $this->gamemode === GameMode::CREATIVE or (!$literal and $this->gamemode === GameMode::SPECTATOR);
|
||||||
return $this->gamemode === GameMode::CREATIVE;
|
|
||||||
}else{
|
|
||||||
return ($this->gamemode & 0x01) === 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1411,11 +1403,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isAdventure(bool $literal = false) : bool{
|
public function isAdventure(bool $literal = false) : bool{
|
||||||
if($literal){
|
return $this->gamemode === GameMode::ADVENTURE or (!$literal and $this->gamemode === GameMode::SPECTATOR);
|
||||||
return $this->gamemode === GameMode::ADVENTURE;
|
|
||||||
}else{
|
|
||||||
return ($this->gamemode & 0x02) > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user