mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-23 19:34:15 +00:00
Cleaned up bool comparison mess
This commit is contained in:
parent
24c5d7557e
commit
ac5a91b67e
@ -116,7 +116,7 @@ abstract class Achievement{
|
||||
public static function broadcast(Player $player, string $achievementId) : bool{
|
||||
if(isset(Achievement::$list[$achievementId])){
|
||||
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::GREEN . Achievement::$list[$achievementId]["name"] . TextFormat::RESET]);
|
||||
if(Server::getInstance()->getConfigBool("announce-player-achievements", true) === true){
|
||||
if(Server::getInstance()->getConfigBool("announce-player-achievements", true)){
|
||||
Server::getInstance()->broadcastMessage($translation);
|
||||
}else{
|
||||
$player->sendMessage($translation);
|
||||
|
@ -72,7 +72,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
return;
|
||||
}
|
||||
|
||||
if($value === true){
|
||||
if($value){
|
||||
$this->server->addOp(strtolower($this->getName()));
|
||||
}else{
|
||||
$this->server->removeOp(strtolower($this->getName()));
|
||||
@ -84,7 +84,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
}
|
||||
|
||||
public function setBanned(bool $value){
|
||||
if($value === true){
|
||||
if($value){
|
||||
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
|
||||
}else{
|
||||
$this->server->getNameBans()->remove($this->getName());
|
||||
@ -96,7 +96,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
||||
}
|
||||
|
||||
public function setWhitelisted(bool $value){
|
||||
if($value === true){
|
||||
if($value){
|
||||
$this->server->addWhitelist(strtolower($this->getName()));
|
||||
}else{
|
||||
$this->server->removeWhitelist(strtolower($this->getName()));
|
||||
|
@ -351,7 +351,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function setBanned(bool $value){
|
||||
if($value === true){
|
||||
if($value){
|
||||
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
|
||||
$this->kick("You have been banned");
|
||||
}else{
|
||||
@ -364,7 +364,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function setWhitelisted(bool $value){
|
||||
if($value === true){
|
||||
if($value){
|
||||
$this->server->addWhitelist($this->iusername);
|
||||
}else{
|
||||
$this->server->removeWhitelist($this->iusername);
|
||||
@ -567,7 +567,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* @return bool
|
||||
*/
|
||||
public function isOnline() : bool{
|
||||
return $this->isConnected() and $this->loggedIn === true;
|
||||
return $this->isConnected() and $this->loggedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -585,7 +585,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
if($value === true){
|
||||
if($value){
|
||||
$this->server->addOp($this->getName());
|
||||
}else{
|
||||
$this->server->removeOp($this->getName());
|
||||
@ -969,7 +969,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
if($this->chunkLoadCount >= $this->spawnThreshold and $this->spawned === false){
|
||||
if($this->chunkLoadCount >= $this->spawnThreshold and !$this->spawned){
|
||||
$this->doFirstSpawn();
|
||||
}
|
||||
}
|
||||
@ -1263,7 +1263,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($this->achievements[$achievementId]) and $this->achievements[$achievementId] !== false;
|
||||
return $this->achievements[$achievementId] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1986,7 +1986,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
protected function processLogin(){
|
||||
foreach($this->server->getLoggedInPlayers() as $p){
|
||||
if($p !== $this and ($p->iusername === $this->iusername or $this->getUniqueId()->equals($p->getUniqueId()))){
|
||||
if($p->kick("logged in from another location") === false){
|
||||
if(!$p->kick("logged in from another location")){
|
||||
$this->close($this->getLeaveMessage(), "Logged in from another location");
|
||||
|
||||
return;
|
||||
@ -2179,7 +2179,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* @return bool
|
||||
*/
|
||||
public function chat(string $message) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2223,7 +2223,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->sendPosition($this, null, null, MovePlayerPacket::MODE_RESET);
|
||||
$this->server->getLogger()->debug("Got outdated pre-teleport movement from " . $this->getName() . ", received " . $newPos . ", expected " . $this->asVector3());
|
||||
//Still getting movements from before teleport, ignore them
|
||||
}elseif((!$this->isAlive() or $this->spawned !== true) and $newPos->distanceSquared($this) > 0.01){
|
||||
}elseif((!$this->isAlive() or !$this->spawned) and $newPos->distanceSquared($this) > 0.01){
|
||||
$this->sendPosition($this, null, null, MovePlayerPacket::MODE_RESET);
|
||||
$this->server->getLogger()->debug("Reverted movement of " . $this->getName() . " due to not alive or not spawned, received " . $newPos . ", locked at " . $this->asVector3());
|
||||
}else{
|
||||
@ -2255,7 +2255,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
$this->resetCraftingGridType();
|
||||
@ -2363,7 +2363,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
if(!$this->canInteract($blockVector->add(0.5, 0.5, 0.5), 13) or $this->isSpectator()){
|
||||
}elseif($this->isCreative()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
if($this->level->useItemOn($blockVector, $item, $face, $packet->trData->clickPos, $this, true) === true){
|
||||
if($this->level->useItemOn($blockVector, $item, $face, $packet->trData->clickPos, $this, true)){
|
||||
return true;
|
||||
}
|
||||
}elseif(!$this->inventory->getItemInHand()->equals($packet->trData->itemInHand)){
|
||||
@ -2499,7 +2499,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
if(!$this->canInteract($target, 8)){
|
||||
$cancelled = true;
|
||||
}elseif($target instanceof Player){
|
||||
if($this->server->getConfigBool("pvp") !== true){
|
||||
if(!$this->server->getConfigBool("pvp")){
|
||||
$cancelled = true;
|
||||
}
|
||||
}
|
||||
@ -2612,7 +2612,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2632,7 +2632,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2687,7 +2687,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
if($this->spawned === false or (!$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE_REQUEST)){
|
||||
if(!$this->spawned or (!$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE_REQUEST)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2740,7 +2740,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->stopSleep();
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_RESPAWN:
|
||||
if($this->spawned === false or $this->isAlive() or !$this->isOnline()){
|
||||
if(!$this->spawned or $this->isAlive() or !$this->isOnline()){
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2803,7 +2803,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2844,7 +2844,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
if($this->spawned === false or $packet->windowId === 0){
|
||||
if(!$this->spawned or $packet->windowId === 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2895,7 +2895,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
$this->resetCraftingGridType();
|
||||
@ -2937,7 +2937,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3485,7 +3485,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
$achievements = new CompoundTag("Achievements");
|
||||
foreach($this->achievements as $achievement => $status){
|
||||
$achievements->setByte($achievement, $status === true ? 1 : 0);
|
||||
$achievements->setByte($achievement, $status ? 1 : 0);
|
||||
}
|
||||
$this->namedtag->setTag($achievements);
|
||||
|
||||
|
@ -272,7 +272,7 @@ class Server{
|
||||
* @return bool
|
||||
*/
|
||||
public function isRunning() : bool{
|
||||
return $this->isRunning === true;
|
||||
return $this->isRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1520,7 +1520,7 @@ class Server{
|
||||
|
||||
$this->scheduler = new ServerScheduler();
|
||||
|
||||
if($this->getConfigBool("enable-rcon", false) === true){
|
||||
if($this->getConfigBool("enable-rcon", false)){
|
||||
try{
|
||||
$this->rcon = new RCON(
|
||||
$this,
|
||||
@ -1564,7 +1564,7 @@ class Server{
|
||||
$this->logger->warning($this->getLanguage()->translateString("pocketmine.server.authProperty.disabled"));
|
||||
}
|
||||
|
||||
if($this->getConfigBool("hardcore", false) === true and $this->getDifficulty() < Level::DIFFICULTY_HARD){
|
||||
if($this->getConfigBool("hardcore", false) and $this->getDifficulty() < Level::DIFFICULTY_HARD){
|
||||
$this->setConfigInt("difficulty", Level::DIFFICULTY_HARD);
|
||||
}
|
||||
|
||||
@ -1639,7 +1639,7 @@ class Server{
|
||||
if(!is_array($options)){
|
||||
continue;
|
||||
}
|
||||
if($this->loadLevel($name) === false){
|
||||
if(!$this->loadLevel($name)){
|
||||
$seed = $options["seed"] ?? time();
|
||||
if(is_string($seed) and !is_numeric($seed)){
|
||||
$seed = Utils::javaStringHash($seed);
|
||||
@ -1668,7 +1668,7 @@ class Server{
|
||||
$default = "world";
|
||||
$this->setConfigString("level-name", "world");
|
||||
}
|
||||
if($this->loadLevel($default) === false){
|
||||
if(!$this->loadLevel($default)){
|
||||
$seed = getopt("", ["level-seed::"])["level-seed"] ?? $this->properties->get("level-seed", time());
|
||||
if(!is_numeric($seed) or bccomp($seed, "9223372036854775807") > 0){
|
||||
$seed = Utils::javaStringHash($seed);
|
||||
@ -1968,7 +1968,7 @@ class Server{
|
||||
$this->properties->reload();
|
||||
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
||||
|
||||
if($this->getConfigBool("hardcore", false) === true and $this->getDifficulty() < Level::DIFFICULTY_HARD){
|
||||
if($this->getConfigBool("hardcore", false) and $this->getDifficulty() < Level::DIFFICULTY_HARD){
|
||||
$this->setConfigInt("difficulty", Level::DIFFICULTY_HARD);
|
||||
}
|
||||
|
||||
@ -2013,7 +2013,7 @@ class Server{
|
||||
$this->rcon->stop();
|
||||
}
|
||||
|
||||
if($this->getProperty("network.upnp-forwarding", false) === true){
|
||||
if($this->getProperty("network.upnp-forwarding", false)){
|
||||
$this->logger->info("[UPnP] Removing port forward...");
|
||||
UPnP::RemovePortForward($this->getPort());
|
||||
}
|
||||
@ -2080,7 +2080,7 @@ class Server{
|
||||
* Starts the PocketMine-MP server and starts processing ticks and packets
|
||||
*/
|
||||
private function start(){
|
||||
if($this->getConfigBool("enable-query", true) === true){
|
||||
if($this->getConfigBool("enable-query", true)){
|
||||
$this->queryHandler = new QueryHandler();
|
||||
}
|
||||
|
||||
@ -2162,7 +2162,7 @@ class Server{
|
||||
}
|
||||
|
||||
public function crashDump(){
|
||||
if($this->isRunning === false){
|
||||
if(!$this->isRunning){
|
||||
return;
|
||||
}
|
||||
if($this->sendUsageTicker > 0){
|
||||
|
@ -176,7 +176,7 @@ class Bed extends Transparent{
|
||||
if(!$down->isTransparent()){
|
||||
$meta = (($player instanceof Player ? $player->getDirection() : 0) - 1) & 0x03;
|
||||
$next = $this->getSide(self::getOtherHalfSide($meta));
|
||||
if($next->canBeReplaced() === true and !$next->getSide(Vector3::SIDE_DOWN)->isTransparent()){
|
||||
if($next->canBeReplaced() and !$next->getSide(Vector3::SIDE_DOWN)->isTransparent()){
|
||||
$this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->id, $meta), true, true);
|
||||
$this->getLevel()->setBlock($next, BlockFactory::get($this->id, $meta | self::BITFLAG_HEAD), true, true);
|
||||
|
||||
|
@ -117,7 +117,7 @@ class Cactus extends Transparent{
|
||||
$block1 = $this->getSide(Vector3::SIDE_SOUTH);
|
||||
$block2 = $this->getSide(Vector3::SIDE_WEST);
|
||||
$block3 = $this->getSide(Vector3::SIDE_EAST);
|
||||
if($block0->isTransparent() === true and $block1->isTransparent() === true and $block2->isTransparent() === true and $block3->isTransparent() === true){
|
||||
if($block0->isTransparent() and $block1->isTransparent() and $block2->isTransparent() and $block3->isTransparent()){
|
||||
$this->getLevel()->setBlock($this, $this, true);
|
||||
|
||||
return true;
|
||||
|
@ -213,7 +213,7 @@ abstract class Door extends Transparent{
|
||||
if($face === Vector3::SIDE_UP){
|
||||
$blockUp = $this->getSide(Vector3::SIDE_UP);
|
||||
$blockDown = $this->getSide(Vector3::SIDE_DOWN);
|
||||
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
|
||||
if(!$blockUp->canBeReplaced() or $blockDown->isTransparent()){
|
||||
return false;
|
||||
}
|
||||
$direction = $player instanceof Player ? $player->getDirection() : 0;
|
||||
@ -226,7 +226,7 @@ abstract class Door extends Transparent{
|
||||
$next = $this->getSide($faces[($direction + 2) % 4]);
|
||||
$next2 = $this->getSide($faces[$direction]);
|
||||
$metaUp = 0x08;
|
||||
if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
|
||||
if($next->getId() === $this->getId() or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
|
||||
$metaUp |= 0x01;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class Ladder extends Transparent{
|
||||
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||
if($blockClicked->isTransparent() === false){
|
||||
if(!$blockClicked->isTransparent()){
|
||||
$faces = [
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
|
@ -67,7 +67,7 @@ class Leaves extends Transparent{
|
||||
}
|
||||
|
||||
|
||||
protected function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
|
||||
protected function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null) : bool{
|
||||
++$check;
|
||||
$index = $pos->x . "." . $pos->y . "." . $pos->z;
|
||||
if(isset($visited[$index])){
|
||||
@ -83,45 +83,45 @@ class Leaves extends Transparent{
|
||||
}
|
||||
if($fromSide === null){
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
if($this->findLog($pos->getSide($side), $visited, $distance + 1, $check, $side) === true){
|
||||
if($this->findLog($pos->getSide($side), $visited, $distance + 1, $check, $side)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{ //No more loops
|
||||
switch($fromSide){
|
||||
case 2:
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_NORTH), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_NORTH), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_WEST), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_WEST), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_EAST), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_EAST), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_SOUTH), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_SOUTH), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_WEST), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_WEST), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_EAST), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_EAST), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_NORTH), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_NORTH), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_SOUTH), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_SOUTH), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_WEST), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_WEST), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_NORTH), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
if($this->findLog($pos->getSide(Vector3::SIDE_NORTH), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_SOUTH), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_SOUTH), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_EAST), $visited, $distance + 1, $check, $fromSide) === true){
|
||||
}elseif($this->findLog($pos->getSide(Vector3::SIDE_EAST), $visited, $distance + 1, $check, $fromSide)){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -151,7 +151,7 @@ class Leaves extends Transparent{
|
||||
|
||||
$this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||
|
||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check)){
|
||||
$this->getLevel()->setBlock($this, $this, false, false);
|
||||
}else{
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
@ -51,7 +51,7 @@ class RedMushroom extends Flowable{
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||
$down = $this->getSide(Vector3::SIDE_DOWN);
|
||||
if($down->isTransparent() === false){
|
||||
if(!$down->isTransparent()){
|
||||
$this->getLevel()->setBlock($blockReplace, $this, true, true);
|
||||
|
||||
return true;
|
||||
|
@ -63,7 +63,7 @@ class Torch extends Flowable{
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||
$below = $this->getSide(Vector3::SIDE_DOWN);
|
||||
|
||||
if($blockClicked->isTransparent() === false and $face !== Vector3::SIDE_DOWN){
|
||||
if(!$blockClicked->isTransparent() and $face !== Vector3::SIDE_DOWN){
|
||||
$faces = [
|
||||
Vector3::SIDE_UP => 5,
|
||||
Vector3::SIDE_NORTH => 4,
|
||||
@ -75,7 +75,7 @@ class Torch extends Flowable{
|
||||
$this->getLevel()->setBlock($blockReplace, $this, true, true);
|
||||
|
||||
return true;
|
||||
}elseif($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL){
|
||||
}elseif(!$below->isTransparent() or $below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL){
|
||||
$this->meta = 0;
|
||||
$this->getLevel()->setBlock($blockReplace, $this, true, true);
|
||||
|
||||
|
@ -308,7 +308,7 @@ abstract class Command{
|
||||
$colored = new TranslationContainer(TextFormat::GRAY . TextFormat::ITALIC . "%chat.type.admin", [$source->getName(), $message]);
|
||||
}
|
||||
|
||||
if($sendToSource === true and !($source instanceof ConsoleCommandSender)){
|
||||
if($sendToSource and !($source instanceof ConsoleCommandSender)){
|
||||
$source->sendMessage($message);
|
||||
}
|
||||
|
||||
|
@ -1723,13 +1723,13 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
return $this->asLocation();
|
||||
}
|
||||
|
||||
public function setPosition(Vector3 $pos){
|
||||
public function setPosition(Vector3 $pos) : bool{
|
||||
if($this->closed){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($pos instanceof Position and $pos->level !== null and $pos->level !== $this->level){
|
||||
if($this->switchLevel($pos->getLevel()) === false){
|
||||
if(!$this->switchLevel($pos->getLevel())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1754,7 +1754,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
public function setPositionAndRotation(Vector3 $pos, float $yaw, float $pitch) : bool{
|
||||
if($this->setPosition($pos) === true){
|
||||
if($this->setPosition($pos)){
|
||||
$this->setRotation($yaw, $pitch);
|
||||
|
||||
return true;
|
||||
@ -1824,7 +1824,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
public function isOnGround() : bool{
|
||||
return $this->onGround === true;
|
||||
return $this->onGround;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1849,7 +1849,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$pos = $ev->getTo();
|
||||
|
||||
$this->setMotion($this->temporalVector->setComponents(0, 0, 0));
|
||||
if($this->setPositionAndRotation($pos, $yaw ?? $this->yaw, $pitch ?? $this->pitch) !== false){
|
||||
if($this->setPositionAndRotation($pos, $yaw ?? $this->yaw, $pitch ?? $this->pitch)){
|
||||
$this->resetFallDistance();
|
||||
$this->onGround = true;
|
||||
|
||||
|
@ -74,7 +74,7 @@ class Squid extends WaterAnimal{
|
||||
|
||||
|
||||
public function entityBaseTick(int $tickDiff = 1) : bool{
|
||||
if($this->closed !== false){
|
||||
if($this->closed){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ abstract class Event{
|
||||
}
|
||||
|
||||
/** @var Event $this */
|
||||
return $this->isCancelled === true;
|
||||
return $this->isCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ class HandlerList{
|
||||
}
|
||||
}
|
||||
}
|
||||
if($changed === true){
|
||||
if($changed){
|
||||
$this->handlers = null;
|
||||
}
|
||||
}elseif($object instanceof RegisteredListener){
|
||||
|
@ -840,7 +840,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* @return bool
|
||||
*/
|
||||
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
||||
if($this->id === $item->getId() and ($checkDamage === false or $this->getDamage() === $item->getDamage())){
|
||||
if($this->id === $item->getId() and (!$checkDamage or $this->getDamage() === $item->getDamage())){
|
||||
if($checkCompound){
|
||||
if($item->getCompoundTag() === $this->getCompoundTag()){
|
||||
return true;
|
||||
|
@ -335,7 +335,7 @@ class ItemFactory{
|
||||
* @throws \InvalidArgumentException if the given string cannot be parsed as an item identifier
|
||||
*/
|
||||
public static function fromString(string $str, bool $multiple = false){
|
||||
if($multiple === true){
|
||||
if($multiple){
|
||||
$blocks = [];
|
||||
foreach(explode(",", $str) as $b){
|
||||
$blocks[] = self::fromString($b, false);
|
||||
|
@ -549,7 +549,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
$ev = new LevelUnloadEvent($this);
|
||||
|
||||
if($this === $this->server->getDefaultLevel() and $force !== true){
|
||||
if($this === $this->server->getDefaultLevel() and !$force){
|
||||
$ev->setCancelled(true);
|
||||
}
|
||||
|
||||
@ -680,7 +680,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* Changes to this function won't be recorded on the version.
|
||||
*/
|
||||
public function checkTime(){
|
||||
if($this->stopTime === true){
|
||||
if($this->stopTime){
|
||||
return;
|
||||
}else{
|
||||
$this->time += 1;
|
||||
@ -771,7 +771,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
Timings::$tickTileEntityTimer->startTiming();
|
||||
//Update tiles that need update
|
||||
foreach($this->updateTiles as $id => $tile){
|
||||
if($tile->onUpdate() !== true){
|
||||
if(!$tile->onUpdate()){
|
||||
unset($this->updateTiles[$id]);
|
||||
}
|
||||
}
|
||||
@ -1529,7 +1529,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
unset($this->blockCache[$chunkHash][$blockHash]);
|
||||
|
||||
if($direct === true){
|
||||
if($direct){
|
||||
$this->sendBlocks($this->getChunkPlayers($pos->x >> 4, $pos->z >> 4), [$block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
unset($this->chunkCache[$chunkHash], $this->changedBlocks[$chunkHash][$blockHash]);
|
||||
}else{
|
||||
@ -1544,7 +1544,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$loader->onBlockChanged($block);
|
||||
}
|
||||
|
||||
if($update === true){
|
||||
if($update){
|
||||
$this->updateAllLight($block);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new BlockUpdateEvent($block));
|
||||
@ -1795,7 +1795,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
if(!$player->isSneaking() and $blockClicked->onActivate($item, $player) === true){
|
||||
if(!$player->isSneaking() and $blockClicked->onActivate($item, $player)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1805,7 +1805,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}elseif($blockClicked->onActivate($item, $player) === true){
|
||||
}elseif($blockClicked->onActivate($item, $player)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2343,7 +2343,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
unset($this->chunkPopulationQueue[$index]);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
$chunk = $this->getChunk($x, $z, false);
|
||||
if($chunk !== null and ($oldChunk === null or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
|
||||
if($chunk !== null and ($oldChunk === null or !$oldChunk->isPopulated()) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($this, $chunk));
|
||||
|
||||
foreach($this->getChunkLoaders($x, $z) as $loader){
|
||||
@ -2719,7 +2719,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function unloadChunkRequest(int $x, int $z, bool $safe = true){
|
||||
if(($safe === true and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){
|
||||
if(($safe and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2733,7 +2733,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function unloadChunk(int $x, int $z, bool $safe = true, bool $trySave = true) : bool{
|
||||
if($safe === true and $this->isChunkInUse($x, $z)){
|
||||
if($safe and $this->isChunkInUse($x, $z)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ class PopulationTask extends AsyncTask{
|
||||
public function onCompletion(Server $server){
|
||||
$level = $server->getLevel($this->levelId);
|
||||
if($level !== null){
|
||||
if($this->state === false){
|
||||
if(!$this->state){
|
||||
$level->registerGenerator();
|
||||
return;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
default:
|
||||
$value = [];
|
||||
}
|
||||
if($types === true){
|
||||
if($types){
|
||||
$data[$key] = [$type, $value];
|
||||
}else{
|
||||
$data[$key] = $value;
|
||||
|
@ -236,7 +236,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$pk = $packet->__encapsulatedPacket;
|
||||
}
|
||||
|
||||
$this->interface->sendEncapsulated($identifier, $pk, ($needACK === true ? RakLib::FLAG_NEED_ACK : 0) | ($immediate === true ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
|
||||
$this->interface->sendEncapsulated($identifier, $pk, ($needACK ? RakLib::FLAG_NEED_ACK : 0) | ($immediate ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
|
||||
return $pk->identifierACK;
|
||||
}else{
|
||||
$this->server->batchPackets([$player], [$packet], true, $immediate);
|
||||
|
@ -84,7 +84,7 @@ class RCON{
|
||||
|
||||
public function check(){
|
||||
for($n = 0; $n < $this->threads; ++$n){
|
||||
if($this->workers[$n]->isTerminated() === true){
|
||||
if($this->workers[$n]->isTerminated()){
|
||||
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
|
||||
}elseif($this->workers[$n]->isWaiting()){
|
||||
if($this->workers[$n]->response !== ""){
|
||||
|
@ -37,7 +37,7 @@ class RCONInstance extends Thread{
|
||||
private $waiting;
|
||||
|
||||
public function isWaiting(){
|
||||
return $this->waiting === true;
|
||||
return $this->waiting;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +72,7 @@ class RCONInstance extends Thread{
|
||||
private function readPacket($client, &$size, &$requestID, &$packetType, &$payload){
|
||||
socket_set_nonblock($client);
|
||||
$d = socket_read($client, 4);
|
||||
if($this->stop === true){
|
||||
if($this->stop){
|
||||
return false;
|
||||
}elseif($d === false){
|
||||
return null;
|
||||
@ -96,7 +96,7 @@ class RCONInstance extends Thread{
|
||||
|
||||
public function run(){
|
||||
$this->registerClassLoader();
|
||||
while($this->stop !== true){
|
||||
while(!$this->stop){
|
||||
$this->synchronized(function(){
|
||||
$this->wait(2000);
|
||||
});
|
||||
@ -117,7 +117,7 @@ class RCONInstance extends Thread{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($done === false){
|
||||
if(!$done){
|
||||
@socket_close($client);
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ class RCONInstance extends Thread{
|
||||
for($n = 0; $n < $this->maxClients; ++$n){
|
||||
$client = &$this->{"client" . $n};
|
||||
if($client !== null){
|
||||
if($this->{"status" . $n} !== -1 and $this->stop !== true){
|
||||
if($this->{"status" . $n} !== -1 and !$this->stop){
|
||||
if($this->{"status" . $n} === 0 and $this->{"timeout" . $n} < microtime(true)){ //Timeout
|
||||
$this->{"status" . $n} = -1;
|
||||
continue;
|
||||
|
@ -31,7 +31,7 @@ use pocketmine\utils\Utils;
|
||||
abstract class UPnP{
|
||||
|
||||
public static function PortForward(int $port) : bool{
|
||||
if(Utils::$online === false){
|
||||
if(!Utils::$online){
|
||||
return false;
|
||||
}
|
||||
if(Utils::getOS() != "win" or !class_exists("COM")){
|
||||
@ -56,7 +56,7 @@ abstract class UPnP{
|
||||
}
|
||||
|
||||
public static function RemovePortForward(int $port) : bool{
|
||||
if(Utils::$online === false){
|
||||
if(!Utils::$online){
|
||||
return false;
|
||||
}
|
||||
if(Utils::getOS() != "win" or !class_exists("COM")){
|
||||
|
@ -48,7 +48,7 @@ class BanList{
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled() : bool{
|
||||
return $this->enabled === true;
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,7 +172,7 @@ class BanList{
|
||||
$this->removeExpired();
|
||||
$fp = @fopen($this->file, "w");
|
||||
if(is_resource($fp)){
|
||||
if($flag === true){
|
||||
if($flag){
|
||||
fwrite($fp, "# Updated " . strftime("%x %H:%M", time()) . " by " . Server::getInstance()->getName() . " " . Server::getInstance()->getPocketMineVersion() . "\n");
|
||||
fwrite($fp, "# victim name | ban date | banned by | banned until | reason\n\n");
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Permission{
|
||||
*/
|
||||
public static function getByName($value) : string{
|
||||
if(is_bool($value)){
|
||||
if($value === true){
|
||||
if($value){
|
||||
return "true";
|
||||
}else{
|
||||
return "false";
|
||||
|
@ -77,7 +77,7 @@ abstract class PluginBase implements Plugin{
|
||||
* @return bool
|
||||
*/
|
||||
final public function isEnabled() : bool{
|
||||
return $this->isEnabled === true;
|
||||
return $this->isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ abstract class PluginBase implements Plugin{
|
||||
final public function setEnabled(bool $boolean = true){
|
||||
if($this->isEnabled !== $boolean){
|
||||
$this->isEnabled = $boolean;
|
||||
if($this->isEnabled === true){
|
||||
if($this->isEnabled){
|
||||
$this->onEnable();
|
||||
}else{
|
||||
$this->onDisable();
|
||||
@ -98,7 +98,7 @@ abstract class PluginBase implements Plugin{
|
||||
* @return bool
|
||||
*/
|
||||
final public function isDisabled() : bool{
|
||||
return $this->isEnabled === false;
|
||||
return !$this->isEnabled;
|
||||
}
|
||||
|
||||
final public function getDataFolder() : string{
|
||||
@ -110,7 +110,7 @@ abstract class PluginBase implements Plugin{
|
||||
}
|
||||
|
||||
final public function init(PluginLoader $loader, Server $server, PluginDescription $description, $dataFolder, $file){
|
||||
if($this->initialized === false){
|
||||
if(!$this->initialized){
|
||||
$this->initialized = true;
|
||||
$this->loader = $loader;
|
||||
$this->server = $server;
|
||||
@ -210,7 +210,7 @@ abstract class PluginBase implements Plugin{
|
||||
mkdir(dirname($out), 0755, true);
|
||||
}
|
||||
|
||||
if(file_exists($out) and $replace !== true){
|
||||
if(file_exists($out) and !$replace){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ abstract class PluginBase implements Plugin{
|
||||
}
|
||||
|
||||
public function saveConfig(){
|
||||
if($this->getConfig()->save() === false){
|
||||
if(!$this->getConfig()->save()){
|
||||
$this->getLogger()->critical("Could not save config to " . $this->configFile);
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ class PluginManager{
|
||||
}
|
||||
}
|
||||
|
||||
if($missingDependency === true){
|
||||
if($missingDependency){
|
||||
foreach($plugins as $name => $file){
|
||||
if(!isset($dependencies[$name])){
|
||||
unset($softDependencies[$name]);
|
||||
@ -325,7 +325,7 @@ class PluginManager{
|
||||
}
|
||||
|
||||
//No plugins loaded :(
|
||||
if($missingDependency === true){
|
||||
if($missingDependency){
|
||||
foreach($plugins as $name => $file){
|
||||
$this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.circularDependency"]));
|
||||
}
|
||||
@ -430,7 +430,7 @@ class PluginManager{
|
||||
* @return Permission[]
|
||||
*/
|
||||
public function getDefaultPermissions(bool $op) : array{
|
||||
if($op === true){
|
||||
if($op){
|
||||
return $this->defaultPermsOp;
|
||||
}else{
|
||||
return $this->defaultPerms;
|
||||
@ -512,7 +512,7 @@ class PluginManager{
|
||||
* @param Permissible $permissible
|
||||
*/
|
||||
public function subscribeToDefaultPerms(bool $op, Permissible $permissible){
|
||||
if($op === true){
|
||||
if($op){
|
||||
$this->defSubsOp[spl_object_hash($permissible)] = $permissible;
|
||||
}else{
|
||||
$this->defSubs[spl_object_hash($permissible)] = $permissible;
|
||||
@ -524,7 +524,7 @@ class PluginManager{
|
||||
* @param Permissible $permissible
|
||||
*/
|
||||
public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible){
|
||||
if($op === true){
|
||||
if($op){
|
||||
unset($this->defSubsOp[spl_object_hash($permissible)]);
|
||||
}else{
|
||||
unset($this->defSubs[spl_object_hash($permissible)]);
|
||||
@ -537,7 +537,7 @@ class PluginManager{
|
||||
* @return Permissible[]
|
||||
*/
|
||||
public function getDefaultPermSubscriptions(bool $op) : array{
|
||||
if($op === true){
|
||||
if($op){
|
||||
return $this->defSubsOp;
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,6 @@ class RegisteredListener{
|
||||
* @return bool
|
||||
*/
|
||||
public function isIgnoringCancelled() : bool{
|
||||
return $this->ignoreCancelled === true;
|
||||
return $this->ignoreCancelled;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ abstract class AsyncTask extends Collectable{
|
||||
public function run(){
|
||||
$this->result = null;
|
||||
|
||||
if($this->cancelRun !== true){
|
||||
if(!$this->cancelRun){
|
||||
try{
|
||||
$this->onRun();
|
||||
}catch(\Throwable $e){
|
||||
@ -90,7 +90,7 @@ abstract class AsyncTask extends Collectable{
|
||||
}
|
||||
|
||||
public function hasCancelledRun() : bool{
|
||||
return $this->cancelRun === true;
|
||||
return $this->cancelRun;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ class TaskHandler{
|
||||
* @return bool
|
||||
*/
|
||||
public function isCancelled() : bool{
|
||||
return $this->cancelled === true;
|
||||
return $this->cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
}
|
||||
|
||||
public function close() : void{
|
||||
if($this->closed === false){
|
||||
if(!$this->closed){
|
||||
$this->inventory->removeAllViewers(true);
|
||||
|
||||
if($this->doubleInventory !== null){
|
||||
|
@ -91,7 +91,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
}
|
||||
|
||||
public function close() : void{
|
||||
if($this->closed === false){
|
||||
if(!$this->closed){
|
||||
$this->inventory->removeAllViewers(true);
|
||||
$this->inventory = null;
|
||||
|
||||
@ -139,7 +139,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
|
||||
}
|
||||
|
||||
public function onUpdate() : bool{
|
||||
if($this->closed === true){
|
||||
if($this->closed){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class Config{
|
||||
$this->config = $default;
|
||||
$this->save();
|
||||
}else{
|
||||
if($this->correct === true){
|
||||
if($this->correct){
|
||||
$content = file_get_contents($this->file);
|
||||
switch($this->type){
|
||||
case Config::PROPERTIES:
|
||||
@ -183,7 +183,7 @@ class Config{
|
||||
* @return bool
|
||||
*/
|
||||
public function check() : bool{
|
||||
return $this->correct === true;
|
||||
return $this->correct;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +192,7 @@ class Config{
|
||||
* @return bool
|
||||
*/
|
||||
public function save(bool $async = false) : bool{
|
||||
if($this->correct === true){
|
||||
if($this->correct){
|
||||
try{
|
||||
$content = null;
|
||||
switch($this->type){
|
||||
@ -456,7 +456,7 @@ class Config{
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($k, bool $lowercase = false) : bool{
|
||||
if($lowercase === true){
|
||||
if($lowercase){
|
||||
$k = strtolower($k); //Convert requested key to lower
|
||||
$array = array_change_key_case($this->config, CASE_LOWER); //Change all keys in array to lower
|
||||
return isset($array[$k]); //Find $k in modified array
|
||||
@ -479,7 +479,7 @@ class Config{
|
||||
* @return array
|
||||
*/
|
||||
public function getAll(bool $keys = false) : array{
|
||||
return ($keys === true ? array_keys($this->config) : $this->config);
|
||||
return ($keys ? array_keys($this->config) : $this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -535,8 +535,8 @@ class Config{
|
||||
private function writeProperties() : string{
|
||||
$content = "#Properties Config file\r\n#" . date("D M j H:i:s T Y") . "\r\n";
|
||||
foreach($this->config as $k => $v){
|
||||
if(is_bool($v) === true){
|
||||
$v = $v === true ? "on" : "off";
|
||||
if(is_bool($v)){
|
||||
$v = $v ? "on" : "off";
|
||||
}elseif(is_array($v)){
|
||||
$v = implode(";", $v);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
}
|
||||
|
||||
public function debug($message, bool $force = false){
|
||||
if($this->logDebug === false and !$force){
|
||||
if(!$this->logDebug and !$force){
|
||||
return;
|
||||
}
|
||||
$this->send($message, \LogLevel::DEBUG, "DEBUG", TextFormat::GRAY);
|
||||
@ -263,7 +263,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
throw new \RuntimeException("Couldn't open log file");
|
||||
}
|
||||
|
||||
while($this->shutdown === false){
|
||||
while(!$this->shutdown){
|
||||
$this->writeLogStream($logResource);
|
||||
$this->synchronized(function(){
|
||||
$this->wait(25000);
|
||||
|
@ -123,50 +123,50 @@ abstract class TextFormat{
|
||||
if($color !== "white"){
|
||||
$pointer["color"] = $color;
|
||||
}
|
||||
if($bold !== false){
|
||||
if($bold){
|
||||
$pointer["bold"] = true;
|
||||
}
|
||||
if($italic !== false){
|
||||
if($italic){
|
||||
$pointer["italic"] = true;
|
||||
}
|
||||
if($underlined !== false){
|
||||
if($underlined){
|
||||
$pointer["underlined"] = true;
|
||||
}
|
||||
if($strikethrough !== false){
|
||||
if($strikethrough){
|
||||
$pointer["strikethrough"] = true;
|
||||
}
|
||||
if($obfuscated !== false){
|
||||
if($obfuscated){
|
||||
$pointer["obfuscated"] = true;
|
||||
}
|
||||
++$index;
|
||||
}
|
||||
switch($token){
|
||||
case TextFormat::BOLD:
|
||||
if($bold === false){
|
||||
if(!$bold){
|
||||
$pointer["bold"] = true;
|
||||
$bold = true;
|
||||
}
|
||||
break;
|
||||
case TextFormat::OBFUSCATED:
|
||||
if($obfuscated === false){
|
||||
if(!$obfuscated){
|
||||
$pointer["obfuscated"] = true;
|
||||
$obfuscated = true;
|
||||
}
|
||||
break;
|
||||
case TextFormat::ITALIC:
|
||||
if($italic === false){
|
||||
if(!$italic){
|
||||
$pointer["italic"] = true;
|
||||
$italic = true;
|
||||
}
|
||||
break;
|
||||
case TextFormat::UNDERLINE:
|
||||
if($underlined === false){
|
||||
if(!$underlined){
|
||||
$pointer["underlined"] = true;
|
||||
$underlined = true;
|
||||
}
|
||||
break;
|
||||
case TextFormat::STRIKETHROUGH:
|
||||
if($strikethrough === false){
|
||||
if(!$strikethrough){
|
||||
$pointer["strikethrough"] = true;
|
||||
$strikethrough = true;
|
||||
}
|
||||
@ -176,23 +176,23 @@ abstract class TextFormat{
|
||||
$pointer["color"] = "white";
|
||||
$color = "white";
|
||||
}
|
||||
if($bold !== false){
|
||||
if($bold){
|
||||
$pointer["bold"] = false;
|
||||
$bold = false;
|
||||
}
|
||||
if($italic !== false){
|
||||
if($italic){
|
||||
$pointer["italic"] = false;
|
||||
$italic = false;
|
||||
}
|
||||
if($underlined !== false){
|
||||
if($underlined){
|
||||
$pointer["underlined"] = false;
|
||||
$underlined = false;
|
||||
}
|
||||
if($strikethrough !== false){
|
||||
if($strikethrough){
|
||||
$pointer["strikethrough"] = false;
|
||||
$strikethrough = false;
|
||||
}
|
||||
if($obfuscated !== false){
|
||||
if($obfuscated){
|
||||
$pointer["obfuscated"] = false;
|
||||
$obfuscated = false;
|
||||
}
|
||||
|
@ -130,9 +130,9 @@ class Utils{
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function getIP(bool $force = false){
|
||||
if(Utils::$online === false){
|
||||
if(!Utils::$online){
|
||||
return false;
|
||||
}elseif(Utils::$ip !== false and $force !== true){
|
||||
}elseif(Utils::$ip !== false and !$force){
|
||||
return Utils::$ip;
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ class Utils{
|
||||
* @throws \RuntimeException if a cURL error occurs
|
||||
*/
|
||||
public static function simpleCurl(string $page, $timeout = 10, array $extraHeaders = [], array $extraOpts = [], callable $onSuccess = null){
|
||||
if(Utils::$online === false){
|
||||
if(!Utils::$online){
|
||||
throw new \RuntimeException("Server is offline");
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class VersionString{
|
||||
}
|
||||
|
||||
public function get(bool $build = false) : string{
|
||||
return $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
|
||||
return $this->getRelease() . ($this->development ? "dev" : "") . (($this->build > 0 and $build) ? "-" . $this->build : "");
|
||||
}
|
||||
|
||||
public function __toString() : string{
|
||||
@ -106,12 +106,12 @@ class VersionString{
|
||||
* @return int
|
||||
*/
|
||||
public function compare($target, bool $diff = false) : int{
|
||||
if(($target instanceof VersionString) === false){
|
||||
if(!($target instanceof VersionString)){
|
||||
$target = new VersionString($target);
|
||||
}
|
||||
$number = $this->getNumber();
|
||||
$tNumber = $target->getNumber();
|
||||
if($diff === true){
|
||||
if($diff){
|
||||
return $tNumber - $number;
|
||||
}
|
||||
if($number > $tNumber){
|
||||
|
Loading…
x
Reference in New Issue
Block a user