mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Replace remaining disallowed operators
This commit is contained in:
parent
61f8144280
commit
4e956d5d1d
@ -168,14 +168,14 @@ class MemoryManager{
|
||||
}
|
||||
|
||||
public function canUseChunkCache() : bool{
|
||||
return !$this->lowMemory or !$this->lowMemDisableChunkCache;
|
||||
return !$this->lowMemory || !$this->lowMemDisableChunkCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the allowed chunk radius based on the current memory usage.
|
||||
*/
|
||||
public function getViewDistance(int $distance) : int{
|
||||
return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? min($this->lowMemChunkRadiusOverride, $distance) : $distance;
|
||||
return ($this->lowMemory && $this->lowMemChunkRadiusOverride > 0) ? min($this->lowMemChunkRadiusOverride, $distance) : $distance;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,18 +214,18 @@ class MemoryManager{
|
||||
public function check() : void{
|
||||
Timings::$memoryManager->startTiming();
|
||||
|
||||
if(($this->memoryLimit > 0 or $this->globalMemoryLimit > 0) and ++$this->checkTicker >= $this->checkRate){
|
||||
if(($this->memoryLimit > 0 || $this->globalMemoryLimit > 0) && ++$this->checkTicker >= $this->checkRate){
|
||||
$this->checkTicker = 0;
|
||||
$memory = Process::getAdvancedMemoryUsage();
|
||||
$trigger = false;
|
||||
if($this->memoryLimit > 0 and $memory[0] > $this->memoryLimit){
|
||||
if($this->memoryLimit > 0 && $memory[0] > $this->memoryLimit){
|
||||
$trigger = 0;
|
||||
}elseif($this->globalMemoryLimit > 0 and $memory[1] > $this->globalMemoryLimit){
|
||||
}elseif($this->globalMemoryLimit > 0 && $memory[1] > $this->globalMemoryLimit){
|
||||
$trigger = 1;
|
||||
}
|
||||
|
||||
if($trigger !== false){
|
||||
if($this->lowMemory and $this->continuousTrigger){
|
||||
if($this->lowMemory && $this->continuousTrigger){
|
||||
if(++$this->continuousTriggerTicker >= $this->continuousTriggerRate){
|
||||
$this->continuousTriggerTicker = 0;
|
||||
$this->trigger($memory[$trigger], $this->memoryLimit, $trigger > 0, ++$this->continuousTriggerCount);
|
||||
@ -240,7 +240,7 @@ class MemoryManager{
|
||||
}
|
||||
}
|
||||
|
||||
if($this->garbageCollectionPeriod > 0 and ++$this->garbageCollectionTicker >= $this->garbageCollectionPeriod){
|
||||
if($this->garbageCollectionPeriod > 0 && ++$this->garbageCollectionTicker >= $this->garbageCollectionPeriod){
|
||||
$this->garbageCollectionTicker = 0;
|
||||
$this->triggerGarbageCollector();
|
||||
}
|
||||
@ -317,7 +317,7 @@ class MemoryManager{
|
||||
$reflection = new \ReflectionClass($className);
|
||||
$staticProperties[$className] = [];
|
||||
foreach($reflection->getProperties() as $property){
|
||||
if(!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className){
|
||||
if(!$property->isStatic() || $property->getDeclaringClass()->getName() !== $className){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ JIT_WARNING
|
||||
|
||||
$exitCode = 0;
|
||||
do{
|
||||
if(!file_exists(Path::join($dataPath, "server.properties")) and !isset($opts["no-wizard"])){
|
||||
if(!file_exists(Path::join($dataPath, "server.properties")) && !isset($opts["no-wizard"])){
|
||||
$installer = new SetupWizard($dataPath);
|
||||
if(!$installer->run()){
|
||||
$exitCode = -1;
|
||||
|
@ -561,7 +561,7 @@ class Server{
|
||||
$ev->call();
|
||||
$class = $ev->getPlayerClass();
|
||||
|
||||
if($offlinePlayerData !== null and ($world = $this->worldManager->getWorldByName($offlinePlayerData->getString("Level", ""))) !== null){
|
||||
if($offlinePlayerData !== null && ($world = $this->worldManager->getWorldByName($offlinePlayerData->getString("Level", ""))) !== null){
|
||||
$playerPos = EntityDataHelper::parseLocation($offlinePlayerData, $world);
|
||||
$spawn = $playerPos->asVector3();
|
||||
}else{
|
||||
@ -721,7 +721,7 @@ class Server{
|
||||
}
|
||||
|
||||
public function isWhitelisted(string $name) : bool{
|
||||
return !$this->hasWhitelist() or $this->operators->exists($name, true) or $this->whitelist->exists($name, true);
|
||||
return !$this->hasWhitelist() || $this->operators->exists($name, true) || $this->whitelist->exists($name, true);
|
||||
}
|
||||
|
||||
public function isOp(string $name) : bool{
|
||||
@ -895,7 +895,7 @@ class Server{
|
||||
}
|
||||
|
||||
$netCompressionLevel = $this->configGroup->getPropertyInt("network.compression-level", 6);
|
||||
if($netCompressionLevel < 1 or $netCompressionLevel > 9){
|
||||
if($netCompressionLevel < 1 || $netCompressionLevel > 9){
|
||||
$this->logger->warning("Invalid network compression level $netCompressionLevel set, setting to default 6");
|
||||
$netCompressionLevel = 6;
|
||||
}
|
||||
@ -912,7 +912,7 @@ class Server{
|
||||
|
||||
$bannedTxt = Path::join($this->dataPath, "banned.txt");
|
||||
$bannedPlayersTxt = Path::join($this->dataPath, "banned-players.txt");
|
||||
if(file_exists($bannedTxt) and !file_exists($bannedPlayersTxt)){
|
||||
if(file_exists($bannedTxt) && !file_exists($bannedPlayersTxt)){
|
||||
@rename($bannedTxt, $bannedPlayersTxt);
|
||||
}
|
||||
@touch($bannedPlayersTxt);
|
||||
@ -934,7 +934,7 @@ class Server{
|
||||
$this->logger->warning($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_server_authProperty_disabled()));
|
||||
}
|
||||
|
||||
if($this->configGroup->getConfigBool("hardcore", false) and $this->getDifficulty() < World::DIFFICULTY_HARD){
|
||||
if($this->configGroup->getConfigBool("hardcore", false) && $this->getDifficulty() < World::DIFFICULTY_HARD){
|
||||
$this->configGroup->setConfigInt("difficulty", World::DIFFICULTY_HARD);
|
||||
}
|
||||
|
||||
@ -984,7 +984,7 @@ class Server{
|
||||
|
||||
$providerManager = new WorldProviderManager();
|
||||
if(
|
||||
($format = $providerManager->getProviderByName($formatName = $this->configGroup->getPropertyString("level-settings.default-format", ""))) !== null and
|
||||
($format = $providerManager->getProviderByName($formatName = $this->configGroup->getPropertyString("level-settings.default-format", ""))) !== null &&
|
||||
$format instanceof WritableWorldProviderManagerEntry
|
||||
){
|
||||
$providerManager->setDefault($format);
|
||||
@ -1381,7 +1381,7 @@ class Server{
|
||||
|
||||
public function enablePlugins(PluginEnableOrder $type) : void{
|
||||
foreach($this->pluginManager->getPlugins() as $plugin){
|
||||
if(!$plugin->isEnabled() and $plugin->getDescription()->getOrder()->equals($type)){
|
||||
if(!$plugin->isEnabled() && $plugin->getDescription()->getOrder()->equals($type)){
|
||||
$this->pluginManager->enablePlugin($plugin);
|
||||
}
|
||||
}
|
||||
@ -1572,7 +1572,7 @@ class Server{
|
||||
|
||||
$stamp = Path::join($this->getDataPath(), "crashdumps", ".last_crash");
|
||||
$crashInterval = 120; //2 minutes
|
||||
if(($lastReportTime = @filemtime($stamp)) !== false and $lastReportTime + $crashInterval >= time()){
|
||||
if(($lastReportTime = @filemtime($stamp)) !== false && $lastReportTime + $crashInterval >= time()){
|
||||
$report = false;
|
||||
$this->logger->debug("Not sending crashdump due to last crash less than $crashInterval seconds ago");
|
||||
}
|
||||
@ -1581,7 +1581,7 @@ class Server{
|
||||
$plugin = $dump->getData()->plugin;
|
||||
if($plugin !== ""){
|
||||
$p = $this->pluginManager->getPlugin($plugin);
|
||||
if($p instanceof Plugin and !($p->getPluginLoader() instanceof PharPluginLoader)){
|
||||
if($p instanceof Plugin && !($p->getPluginLoader() instanceof PharPluginLoader)){
|
||||
$this->logger->debug("Not sending crashdump due to caused by non-phar plugin");
|
||||
$report = false;
|
||||
}
|
||||
@ -1591,7 +1591,7 @@ class Server{
|
||||
$report = false;
|
||||
}
|
||||
|
||||
if(strrpos(VersionInfo::GIT_HASH(), "-dirty") !== false or VersionInfo::GIT_HASH() === str_repeat("00", 20)){
|
||||
if(strrpos(VersionInfo::GIT_HASH(), "-dirty") !== false || VersionInfo::GIT_HASH() === str_repeat("00", 20)){
|
||||
$this->logger->debug("Not sending crashdump due to locally modified");
|
||||
$report = false; //Don't send crashdumps for locally modified builds
|
||||
}
|
||||
@ -1606,8 +1606,8 @@ class Server{
|
||||
"reportPaste" => base64_encode($dump->getEncodedData())
|
||||
], 10, [], $postUrlError);
|
||||
|
||||
if($reply !== null and ($data = json_decode($reply->getBody())) !== null){
|
||||
if(isset($data->crashId) and isset($data->crashUrl)){
|
||||
if($reply !== null && ($data = json_decode($reply->getBody())) !== null){
|
||||
if(isset($data->crashId) && isset($data->crashUrl)){
|
||||
$reportId = $data->crashId;
|
||||
$reportUrl = $data->crashUrl;
|
||||
$this->logger->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_crash_archive($reportUrl, (string) $reportId)));
|
||||
@ -1664,7 +1664,7 @@ class Server{
|
||||
public function addOnlinePlayer(Player $player) : bool{
|
||||
$ev = new PlayerLoginEvent($player, "Plugin reason");
|
||||
$ev->call();
|
||||
if($ev->isCancelled() or !$player->isConnected()){
|
||||
if($ev->isCancelled() || !$player->isConnected()){
|
||||
$player->disconnect($ev->getKickMessage());
|
||||
|
||||
return false;
|
||||
@ -1793,7 +1793,7 @@ class Server{
|
||||
$this->network->getBandwidthTracker()->rotateAverageHistory();
|
||||
}
|
||||
|
||||
if($this->sendUsageTicker > 0 and --$this->sendUsageTicker === 0){
|
||||
if($this->sendUsageTicker > 0 && --$this->sendUsageTicker === 0){
|
||||
$this->sendUsageTicker = 6000;
|
||||
$this->sendUsage(SendUsageTask::TYPE_STATUS);
|
||||
}
|
||||
|
@ -222,10 +222,10 @@ class CrashDump{
|
||||
}
|
||||
}
|
||||
|
||||
if($this->server->getConfigGroup()->getPropertyBool("auto-report.send-code", true) and file_exists($error["fullFile"])){
|
||||
if($this->server->getConfigGroup()->getPropertyBool("auto-report.send-code", true) && file_exists($error["fullFile"])){
|
||||
$file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
|
||||
if($file !== false){
|
||||
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10 and isset($file[$l]); ++$l){
|
||||
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10 && isset($file[$l]); ++$l){
|
||||
$this->data->code[$l + 1] = $file[$l];
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ abstract class LegacyToStringBidirectionalIdMap{
|
||||
throw new AssumptionFailedError("Invalid format of ID map");
|
||||
}
|
||||
foreach($stringToLegacyId as $stringId => $legacyId){
|
||||
if(!is_string($stringId) or !is_int($legacyId)){
|
||||
if(!is_string($stringId) || !is_int($legacyId)){
|
||||
throw new AssumptionFailedError("ID map should have string keys and int values");
|
||||
}
|
||||
$this->legacyToString[$legacyId] = $stringId;
|
||||
|
@ -135,7 +135,7 @@ class Language{
|
||||
*/
|
||||
public function translateString(string $str, array $params = [], ?string $onlyPrefix = null) : string{
|
||||
$baseText = $this->get($str);
|
||||
$baseText = $this->parseTranslation(($onlyPrefix === null or strpos($str, $onlyPrefix) === 0) ? $baseText : $str, $onlyPrefix);
|
||||
$baseText = $this->parseTranslation(($onlyPrefix === null || strpos($str, $onlyPrefix) === 0) ? $baseText : $str, $onlyPrefix);
|
||||
|
||||
foreach($params as $i => $p){
|
||||
$replacement = $p instanceof Translatable ? $this->translate($p) : (string) $p;
|
||||
@ -176,14 +176,14 @@ class Language{
|
||||
if($replaceString !== null){
|
||||
$ord = ord($c);
|
||||
if(
|
||||
($ord >= 0x30 and $ord <= 0x39) // 0-9
|
||||
or ($ord >= 0x41 and $ord <= 0x5a) // A-Z
|
||||
or ($ord >= 0x61 and $ord <= 0x7a) or // a-z
|
||||
$c === "." or $c === "-"
|
||||
($ord >= 0x30 && $ord <= 0x39) // 0-9
|
||||
|| ($ord >= 0x41 && $ord <= 0x5a) // A-Z
|
||||
|| ($ord >= 0x61 && $ord <= 0x7a) || // a-z
|
||||
$c === "." || $c === "-"
|
||||
){
|
||||
$replaceString .= $c;
|
||||
}else{
|
||||
if(($t = $this->internalGet(substr($replaceString, 1))) !== null and ($onlyPrefix === null or strpos($replaceString, $onlyPrefix) === 1)){
|
||||
if(($t = $this->internalGet(substr($replaceString, 1))) !== null && ($onlyPrefix === null || strpos($replaceString, $onlyPrefix) === 1)){
|
||||
$newString .= $t;
|
||||
}else{
|
||||
$newString .= $replaceString;
|
||||
@ -204,7 +204,7 @@ class Language{
|
||||
}
|
||||
|
||||
if($replaceString !== null){
|
||||
if(($t = $this->internalGet(substr($replaceString, 1))) !== null and ($onlyPrefix === null or strpos($replaceString, $onlyPrefix) === 1)){
|
||||
if(($t = $this->internalGet(substr($replaceString, 1))) !== null && ($onlyPrefix === null || strpos($replaceString, $onlyPrefix) === 1)){
|
||||
$newString .= $t;
|
||||
}else{
|
||||
$newString .= $replaceString;
|
||||
|
@ -76,7 +76,7 @@ class ZippedResourcePack implements ResourcePack{
|
||||
for($i = 0; $i < $archive->numFiles; ++$i){
|
||||
$name = Utils::assumeNotFalse($archive->getNameIndex($i), "This index should be valid");
|
||||
if(
|
||||
($manifestPath === null or strlen($name) < strlen($manifestPath)) and
|
||||
($manifestPath === null || strlen($name) < strlen($manifestPath)) &&
|
||||
preg_match('#.*/manifest.json$#', $name) === 1
|
||||
){
|
||||
$manifestPath = $name;
|
||||
@ -146,7 +146,7 @@ class ZippedResourcePack implements ResourcePack{
|
||||
}
|
||||
|
||||
public function getSha256(bool $cached = true) : string{
|
||||
if($this->sha256 === null or !$cached){
|
||||
if($this->sha256 === null || !$cached){
|
||||
$this->sha256 = hash_file("sha256", $this->path, true);
|
||||
}
|
||||
return $this->sha256;
|
||||
|
@ -45,7 +45,7 @@ class ThreadManager extends \Volatile{
|
||||
* @param Worker|Thread $thread
|
||||
*/
|
||||
public function add($thread) : void{
|
||||
if($thread instanceof Thread or $thread instanceof Worker){
|
||||
if($thread instanceof Thread || $thread instanceof Worker){
|
||||
$this[spl_object_id($thread)] = $thread;
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ class ThreadManager extends \Volatile{
|
||||
* @param Worker|Thread $thread
|
||||
*/
|
||||
public function remove($thread) : void{
|
||||
if($thread instanceof Thread or $thread instanceof Worker){
|
||||
if($thread instanceof Thread || $thread instanceof Worker){
|
||||
unset($this[spl_object_id($thread)]);
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ LICENSE;
|
||||
private function askPort(Translatable $prompt, int $default) : int{
|
||||
while(true){
|
||||
$port = (int) $this->getInput($this->lang->translate($prompt), (string) $default);
|
||||
if($port <= 0 or $port > 65535){
|
||||
if($port <= 0 || $port > 65535){
|
||||
$this->error($this->lang->translate(KnownTranslationFactory::invalid_port()));
|
||||
continue;
|
||||
}
|
||||
@ -264,7 +264,7 @@ LICENSE;
|
||||
private function getInput(string $message, string $default = "", string $options = "") : string{
|
||||
$message = "[?] " . $message;
|
||||
|
||||
if($options !== "" or $default !== ""){
|
||||
if($options !== "" || $default !== ""){
|
||||
$message .= " (" . ($options === "" ? $default : $options) . ")";
|
||||
}
|
||||
$message .= ": ";
|
||||
|
Loading…
x
Reference in New Issue
Block a user