Unnecessary arguments in the if expression

This commit is contained in:
Sunch 2024-08-17 19:58:16 +08:00
parent f9f4e65571
commit 4630481d54
9 changed files with 13 additions and 13 deletions

View file

@ -130,7 +130,7 @@ class AchievementAPI{
return false; return false;
} }
if(!isset($player->achievements[$achievementId]) or $player->achievements[$achievementId] == false){ if(!isset($player->achievements[$achievementId]) or !$player->achievements[$achievementId]){
return false; return false;
} }
return true; return true;
@ -140,7 +140,7 @@ class AchievementAPI{
if(isset(self::$achievements[$achievementId])){ if(isset(self::$achievements[$achievementId])){
$result = ServerAPI::request()->api->dhandle("achievement.broadcast", ["player" => $player, "achievementId" => $achievementId]); $result = ServerAPI::request()->api->dhandle("achievement.broadcast", ["player" => $player, "achievementId" => $achievementId]);
if($result !== false and $result !== true){ if($result !== false and $result !== true){
if(ServerAPI::request()->api->getProperty("announce-player-achievements") == true){ if(ServerAPI::request()->api->getProperty("announce-player-achievements")){
ServerAPI::request()->api->chat->broadcast($player->username . " has just earned the achievement [" . self::$achievements[$achievementId]["name"] . "]"); ServerAPI::request()->api->chat->broadcast($player->username . " has just earned the achievement [" . self::$achievements[$achievementId]["name"] . "]");
}else{ }else{
$player->sendChat("You have just earned the achievement [" . self::$achievements[$achievementId]["name"] . "]"); $player->sendChat("You have just earned the achievement [" . self::$achievements[$achievementId]["name"] . "]");

View file

@ -152,7 +152,7 @@ class ServerAPI{
//define("MAX_CHUNK_RATE", 20 / $this->getProperty("max-chunks-per-second", 8)); //Default rate ~512 kB/s //define("MAX_CHUNK_RATE", 20 / $this->getProperty("max-chunks-per-second", 8)); //Default rate ~512 kB/s
MobSpawner::$spawnAnimals = $this->getProperty("spawn-animals"); MobSpawner::$spawnAnimals = $this->getProperty("spawn-animals");
MobSpawner::$spawnMobs = $this->getProperty("spawn-mobs"); MobSpawner::$spawnMobs = $this->getProperty("spawn-mobs");
if($this->getProperty("upnp-forwarding") == true){ if($this->getProperty("upnp-forwarding")){
console("[INFO] [UPnP] Trying to port forward..."); console("[INFO] [UPnP] Trying to port forward...");
UPnP_PortForward($this->getProperty("server-port")); UPnP_PortForward($this->getProperty("server-port"));
} }
@ -245,7 +245,7 @@ class ServerAPI{
public function setProperty($name, $value, $save = true){ public function setProperty($name, $value, $save = true){
$this->config->set($name, $value); $this->config->set($name, $value);
if($save == true){ if($save){
$this->writeProperties(); $this->writeProperties();
} }
$this->loadProperties(); $this->loadProperties();

View file

@ -106,7 +106,7 @@ class PocketMinecraftServer{
if(self::$FORCE_20_TPS){ if(self::$FORCE_20_TPS){
ConsoleAPI::warn("Forcing 20 tps. This may result in higher CPU usage!"); ConsoleAPI::warn("Forcing 20 tps. This may result in higher CPU usage!");
} }
if($this->extraprops->get("discord-msg") == true){ if($this->extraprops->get("discord-msg")){
if($this->extraprops->get("discord-webhook-url") !== "none"){ if($this->extraprops->get("discord-webhook-url") !== "none"){
console("[INFO] Discord Logger is enabled."); console("[INFO] Discord Logger is enabled.");
}else{ }else{
@ -226,7 +226,7 @@ class PocketMinecraftServer{
} }
public function send2Discord($msg){ public function send2Discord($msg){
if($this->extraprops->get("discord-msg") == true and $this->extraprops->get("discord-webhook-url") !== "none"){ if($this->extraprops->get("discord-msg") and $this->extraprops->get("discord-webhook-url") !== "none"){
$url = $this->extraprops->get("discord-webhook-url"); $url = $this->extraprops->get("discord-webhook-url");
$name = $this->extraprops->get("discord-bot-name"); $name = $this->extraprops->get("discord-bot-name");
$this->asyncOperation(ASYNC_CURL_POST, [ $this->asyncOperation(ASYNC_CURL_POST, [

View file

@ -130,7 +130,7 @@ ini_set("opcache.mmap_base", bin2hex(Utils::getRandomBytes(8, false))); //Fix OP
define("SOURCE_SHA1SUM", bin2hex($sha1sum)); define("SOURCE_SHA1SUM", bin2hex($sha1sum));
/***REM_START***/ /***REM_START***/
if(!file_exists(DATA_PATH . "server.properties") and arg("no-wizard", false) != true){ if(!file_exists(DATA_PATH . "server.properties") and !arg("no-wizard", false)){
$installer = new Installer(); $installer = new Installer();
} }
/***REM_END***/ /***REM_END***/

View file

@ -15,7 +15,7 @@ class SetTimePacket extends RakNetDataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->time); $this->putInt($this->time);
$this->putByte($this->started == true ? 0x80:0x00); $this->putByte($this->started ? 0x80:0x00);
} }
} }

View file

@ -39,7 +39,7 @@ class QueryHandler{
public function regenerateInfo(){ public function regenerateInfo(){
$str = ""; $str = "";
$plist = "NostalgiaCore " . MAJOR_VERSION; $plist = "NostalgiaCore " . MAJOR_VERSION;
if($this->server->extraprops->get("query-plugins") == true){ if($this->server->extraprops->get("query-plugins")){
$pl = $this->server->api->plugin->getList(); $pl = $this->server->api->plugin->getList();
if(count($pl) > 0){ if(count($pl) > 0){
$plist .= ":"; $plist .= ":";

View file

@ -143,7 +143,7 @@ class RakNetParser{
$orderChannel = false; $orderChannel = false;
} }
if($hasSplit == true){ if($hasSplit){
$splitCount = $this->getInt(); $splitCount = $this->getInt();
$splitID = $this->getShort(); $splitID = $this->getShort();
$splitIndex = $this->getInt(); $splitIndex = $this->getInt();

View file

@ -4,7 +4,7 @@ class StopMessageThread extends Thread
{ {
private $page, $msg; private $page, $msg;
public function __construct(PocketMinecraftServer $server, $msg){ public function __construct(PocketMinecraftServer $server, $msg){
if($server->extraprops->get("discord-msg") == true and ($this->page = $server->extraprops->get("discord-webhook-url")) !== "none"){ if($server->extraprops->get("discord-msg") and ($this->page = $server->extraprops->get("discord-webhook-url")) !== "none"){
$this->msg = $server->extraprops->get("discord-ru-smiles") ? str_replace("@", " ", str_replace("Ы", "<:ru_cool:960113011383738369>", str_replace("Ь", "<:ru_cry:960112920346390548>", str_replace("Ъ", "<:ru_happy:960112868601237504>", $msg)))) : str_replace("@", "", $msg); $this->msg = $server->extraprops->get("discord-ru-smiles") ? str_replace("@", " ", str_replace("Ы", "<:ru_cool:960113011383738369>", str_replace("Ь", "<:ru_cry:960112920346390548>", str_replace("Ъ", "<:ru_happy:960112868601237504>", $msg)))) : str_replace("@", "", $msg);
$this->name = $server->extraprops->get("discord-bot-name"); $this->name = $server->extraprops->get("discord-bot-name");
$this->start(); $this->start();

View file

@ -376,7 +376,7 @@ class Level{
if(count($this->players) == 0) return false; if(count($this->players) == 0) return false;
if($this->server->api->time->getPhase($this) === "night"){ //TODO vanilla if($this->server->api->time->getPhase($this) === "night"){ //TODO vanilla
foreach($this->players as $p){ foreach($this->players as $p){
if($p->isSleeping == false || $p->sleepingTime < 100){ if(!$p->isSleeping || $p->sleepingTime < 100){
return false; return false;
} }
} }
@ -906,7 +906,7 @@ class Level{
return false; return false;
} }
$now = microtime(true); $now = microtime(true);
if($this->stopTime == true){ if($this->stopTime){
$time = $this->startTime; $time = $this->startTime;
}else{ }else{
$time = $this->startTime + ($now - $this->startCheck) * 20; $time = $this->startTime + ($now - $this->startCheck) * 20;