Isolate config casting nastiness in one place

this doesn't solve the underlying problem, but it does reduce the amount of noise made by PHPStan about it, as well as avoiding code litter.
This commit is contained in:
Dylan K. Taylor 2021-06-19 19:14:02 +01:00
parent 11b483f2dc
commit 981b0285d1
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
13 changed files with 73 additions and 116 deletions

View File

@ -191,7 +191,7 @@ class CrashDump{
private function extraData() : void{ private function extraData() : void{
global $argv; global $argv;
if($this->server->getConfigGroup()->getProperty("auto-report.send-settings", true) !== false){ if($this->server->getConfigGroup()->getPropertyBool("auto-report.send-settings", true)){
$this->data["parameters"] = (array) $argv; $this->data["parameters"] = (array) $argv;
if(($serverDotProperties = @file_get_contents($this->server->getDataPath() . "server.properties")) !== false){ if(($serverDotProperties = @file_get_contents($this->server->getDataPath() . "server.properties")) !== false){
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $serverDotProperties); $this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $serverDotProperties);
@ -214,7 +214,7 @@ class CrashDump{
} }
$this->data["extensions"] = $extensions; $this->data["extensions"] = $extensions;
if($this->server->getConfigGroup()->getProperty("auto-report.send-phpinfo", true) !== false){ if($this->server->getConfigGroup()->getPropertyBool("auto-report.send-phpinfo", true)){
ob_start(); ob_start();
phpinfo(); phpinfo();
$this->data["phpinfo"] = ob_get_contents(); $this->data["phpinfo"] = ob_get_contents();
@ -276,7 +276,7 @@ class CrashDump{
$this->addLine("Code:"); $this->addLine("Code:");
$this->data["code"] = []; $this->data["code"] = [];
if($this->server->getConfigGroup()->getProperty("auto-report.send-code", true) !== false and file_exists($error["fullFile"])){ if($this->server->getConfigGroup()->getPropertyBool("auto-report.send-code", true) and file_exists($error["fullFile"])){
$file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES); $file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
if($file !== false){ 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 and isset($file[$l]); ++$l){

View File

@ -123,7 +123,7 @@ class MemoryManager{
} }
private function init(ServerConfigGroup $config) : void{ private function init(ServerConfigGroup $config) : void{
$this->memoryLimit = ((int) $config->getProperty("memory.main-limit", 0)) * 1024 * 1024; $this->memoryLimit = $config->getPropertyInt("memory.main-limit", 0) * 1024 * 1024;
$defaultMemory = 1024; $defaultMemory = 1024;
@ -149,7 +149,7 @@ class MemoryManager{
} }
} }
$hardLimit = ((int) $config->getProperty("memory.main-hard-limit", $defaultMemory)); $hardLimit = $config->getPropertyInt("memory.main-hard-limit", $defaultMemory);
if($hardLimit <= 0){ if($hardLimit <= 0){
ini_set("memory_limit", '-1'); ini_set("memory_limit", '-1');
@ -157,22 +157,22 @@ class MemoryManager{
ini_set("memory_limit", $hardLimit . "M"); ini_set("memory_limit", $hardLimit . "M");
} }
$this->globalMemoryLimit = ((int) $config->getProperty("memory.global-limit", 0)) * 1024 * 1024; $this->globalMemoryLimit = $config->getPropertyInt("memory.global-limit", 0) * 1024 * 1024;
$this->checkRate = (int) $config->getProperty("memory.check-rate", 20); $this->checkRate = $config->getPropertyInt("memory.check-rate", 20);
$this->continuousTrigger = (bool) $config->getProperty("memory.continuous-trigger", true); $this->continuousTrigger = $config->getPropertyBool("memory.continuous-trigger", true);
$this->continuousTriggerRate = (int) $config->getProperty("memory.continuous-trigger-rate", 30); $this->continuousTriggerRate = $config->getPropertyInt("memory.continuous-trigger-rate", 30);
$this->garbageCollectionPeriod = (int) $config->getProperty("memory.garbage-collection.period", 36000); $this->garbageCollectionPeriod = $config->getPropertyInt("memory.garbage-collection.period", 36000);
$this->garbageCollectionTrigger = (bool) $config->getProperty("memory.garbage-collection.low-memory-trigger", true); $this->garbageCollectionTrigger = $config->getPropertyBool("memory.garbage-collection.low-memory-trigger", true);
$this->garbageCollectionAsync = (bool) $config->getProperty("memory.garbage-collection.collect-async-worker", true); $this->garbageCollectionAsync = $config->getPropertyBool("memory.garbage-collection.collect-async-worker", true);
$this->lowMemChunkRadiusOverride = (int) $config->getProperty("memory.max-chunks.chunk-radius", 4); $this->lowMemChunkRadiusOverride = $config->getPropertyInt("memory.max-chunks.chunk-radius", 4);
$this->lowMemChunkGC = (bool) $config->getProperty("memory.max-chunks.trigger-chunk-collect", true); $this->lowMemChunkGC = $config->getPropertyBool("memory.max-chunks.trigger-chunk-collect", true);
$this->lowMemDisableChunkCache = (bool) $config->getProperty("memory.world-caches.disable-chunk-cache", true); $this->lowMemDisableChunkCache = $config->getPropertyBool("memory.world-caches.disable-chunk-cache", true);
$this->lowMemClearWorldCache = (bool) $config->getProperty("memory.world-caches.low-memory-trigger", true); $this->lowMemClearWorldCache = $config->getPropertyBool("memory.world-caches.low-memory-trigger", true);
$this->dumpWorkers = (bool) $config->getProperty("memory.memory-dump.dump-async-worker", true); $this->dumpWorkers = $config->getPropertyBool("memory.memory-dump.dump-async-worker", true);
gc_enable(); gc_enable();
} }

View File

@ -496,7 +496,7 @@ class Server{
} }
public function shouldSavePlayerData() : bool{ public function shouldSavePlayerData() : bool{
return (bool) $this->configGroup->getProperty("player.save-player-data", true); return $this->configGroup->getPropertyBool("player.save-player-data", true);
} }
/** /**
@ -858,13 +858,13 @@ class Server{
]) ])
); );
$debugLogLevel = (int) $this->configGroup->getProperty("debug.level", 1); $debugLogLevel = $this->configGroup->getPropertyInt("debug.level", 1);
if($this->logger instanceof MainLogger){ if($this->logger instanceof MainLogger){
$this->logger->setLogDebug($debugLogLevel > 1); $this->logger->setLogDebug($debugLogLevel > 1);
} }
$this->forceLanguage = (bool) $this->configGroup->getProperty("settings.force-language", false); $this->forceLanguage = $this->configGroup->getPropertyBool("settings.force-language", false);
$selectedLang = $this->configGroup->getConfigString("language", $this->configGroup->getProperty("settings.language", Language::FALLBACK_LANGUAGE)); $selectedLang = $this->configGroup->getConfigString("language", $this->configGroup->getPropertyString("settings.language", Language::FALLBACK_LANGUAGE));
try{ try{
$this->language = new Language($selectedLang); $this->language = new Language($selectedLang);
}catch(LanguageNotFoundException $e){ }catch(LanguageNotFoundException $e){
@ -880,7 +880,7 @@ class Server{
$this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()])); $this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()]));
if(VersionInfo::IS_DEVELOPMENT_BUILD){ if(VersionInfo::IS_DEVELOPMENT_BUILD){
if(!((bool) $this->configGroup->getProperty("settings.enable-dev-builds", false))){ if(!$this->configGroup->getPropertyBool("settings.enable-dev-builds", false)){
$this->logger->emergency($this->language->translateString("pocketmine.server.devBuild.error1", [VersionInfo::NAME])); $this->logger->emergency($this->language->translateString("pocketmine.server.devBuild.error1", [VersionInfo::NAME]));
$this->logger->emergency($this->language->translateString("pocketmine.server.devBuild.error2")); $this->logger->emergency($this->language->translateString("pocketmine.server.devBuild.error2"));
$this->logger->emergency($this->language->translateString("pocketmine.server.devBuild.error3")); $this->logger->emergency($this->language->translateString("pocketmine.server.devBuild.error3"));
@ -902,7 +902,7 @@ class Server{
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion() . TextFormat::RESET])); $this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion() . TextFormat::RESET]));
if(($poolSize = $this->configGroup->getProperty("settings.async-workers", "auto")) === "auto"){ if(($poolSize = $this->configGroup->getPropertyString("settings.async-workers", "auto")) === "auto"){
$poolSize = 2; $poolSize = 2;
$processors = Utils::getCoreCount() - 2; $processors = Utils::getCoreCount() - 2;
@ -913,25 +913,25 @@ class Server{
$poolSize = max(1, (int) $poolSize); $poolSize = max(1, (int) $poolSize);
} }
$this->asyncPool = new AsyncPool($poolSize, max(-1, (int) $this->configGroup->getProperty("memory.async-worker-hard-limit", 256)), $this->autoloader, $this->logger, $this->tickSleeper); $this->asyncPool = new AsyncPool($poolSize, max(-1, $this->configGroup->getPropertyInt("memory.async-worker-hard-limit", 256)), $this->autoloader, $this->logger, $this->tickSleeper);
$netCompressionThreshold = -1; $netCompressionThreshold = -1;
if($this->configGroup->getProperty("network.batch-threshold", 256) >= 0){ if($this->configGroup->getPropertyInt("network.batch-threshold", 256) >= 0){
$netCompressionThreshold = (int) $this->configGroup->getProperty("network.batch-threshold", 256); $netCompressionThreshold = $this->configGroup->getPropertyInt("network.batch-threshold", 256);
} }
$netCompressionLevel = (int) $this->configGroup->getProperty("network.compression-level", 6); $netCompressionLevel = $this->configGroup->getPropertyInt("network.compression-level", 6);
if($netCompressionLevel < 1 or $netCompressionLevel > 9){ if($netCompressionLevel < 1 or $netCompressionLevel > 9){
$this->logger->warning("Invalid network compression level $netCompressionLevel set, setting to default 6"); $this->logger->warning("Invalid network compression level $netCompressionLevel set, setting to default 6");
$netCompressionLevel = 6; $netCompressionLevel = 6;
} }
ZlibCompressor::setInstance(new ZlibCompressor($netCompressionLevel, $netCompressionThreshold, ZlibCompressor::DEFAULT_MAX_DECOMPRESSION_SIZE)); ZlibCompressor::setInstance(new ZlibCompressor($netCompressionLevel, $netCompressionThreshold, ZlibCompressor::DEFAULT_MAX_DECOMPRESSION_SIZE));
$this->networkCompressionAsync = (bool) $this->configGroup->getProperty("network.async-compression", true); $this->networkCompressionAsync = $this->configGroup->getPropertyBool("network.async-compression", true);
EncryptionContext::$ENABLED = (bool) $this->configGroup->getProperty("network.enable-encryption", true); EncryptionContext::$ENABLED = $this->configGroup->getPropertyBool("network.enable-encryption", true);
$this->doTitleTick = ((bool) $this->configGroup->getProperty("console.title-tick", true)) && Terminal::hasFormattingCodes(); $this->doTitleTick = $this->configGroup->getPropertyBool("console.title-tick", true) && Terminal::hasFormattingCodes();
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM); $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM); $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
@ -977,8 +977,8 @@ class Server{
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()])); $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
Timings::init(); Timings::init();
TimingsHandler::setEnabled((bool) $this->configGroup->getProperty("settings.enable-profiling", false)); TimingsHandler::setEnabled($this->configGroup->getPropertyBool("settings.enable-profiling", false));
$this->profilingTickRate = (float) $this->configGroup->getProperty("settings.profile-report-trigger", 20); $this->profilingTickRate = $this->configGroup->getPropertyInt("settings.profile-report-trigger", 20);
DefaultPermissions::registerCorePermissions(); DefaultPermissions::registerCorePermissions();
@ -1000,13 +1000,13 @@ class Server{
$this->forceShutdown(); $this->forceShutdown();
return; return;
} }
$this->pluginManager = new PluginManager($this, ((bool) $this->configGroup->getProperty("plugins.legacy-data-dir", true)) ? null : $this->getDataPath() . "plugin_data" . DIRECTORY_SEPARATOR, $pluginGraylist); $this->pluginManager = new PluginManager($this, $this->configGroup->getPropertyBool("plugins.legacy-data-dir", true) ? null : $this->getDataPath() . "plugin_data" . DIRECTORY_SEPARATOR, $pluginGraylist);
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader)); $this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
$this->pluginManager->registerInterface(new ScriptPluginLoader()); $this->pluginManager->registerInterface(new ScriptPluginLoader());
$providerManager = new WorldProviderManager(); $providerManager = new WorldProviderManager();
if( if(
($format = $providerManager->getProviderByName($formatName = (string) $this->configGroup->getProperty("level-settings.default-format"))) !== null and ($format = $providerManager->getProviderByName($formatName = $this->configGroup->getPropertyString("level-settings.default-format", ""))) !== null and
is_a($format, WritableWorldProvider::class, true) is_a($format, WritableWorldProvider::class, true)
){ ){
$providerManager->setDefault($format); $providerManager->setDefault($format);
@ -1016,9 +1016,9 @@ class Server{
$this->worldManager = new WorldManager($this, $this->dataPath . "/worlds", $providerManager); $this->worldManager = new WorldManager($this, $this->dataPath . "/worlds", $providerManager);
$this->worldManager->setAutoSave($this->configGroup->getConfigBool("auto-save", $this->worldManager->getAutoSave())); $this->worldManager->setAutoSave($this->configGroup->getConfigBool("auto-save", $this->worldManager->getAutoSave()));
$this->worldManager->setAutoSaveInterval((int) $this->configGroup->getProperty("ticks-per.autosave", 6000)); $this->worldManager->setAutoSaveInterval($this->configGroup->getPropertyInt("ticks-per.autosave", 6000));
$this->updater = new AutoUpdater($this, $this->configGroup->getProperty("auto-updater.host", "update.pmmp.io")); $this->updater = new AutoUpdater($this, $this->configGroup->getPropertyString("auto-updater.host", "update.pmmp.io"));
$this->queryInfo = new QueryInfo($this); $this->queryInfo = new QueryInfo($this);
@ -1107,11 +1107,11 @@ class Server{
$this->network->blockAddress($entry->getName(), -1); $this->network->blockAddress($entry->getName(), -1);
} }
if((bool) $this->configGroup->getProperty("network.upnp-forwarding", false)){ if($this->configGroup->getPropertyBool("network.upnp-forwarding", false)){
$this->network->registerInterface(new UPnPNetworkInterface($this->logger, Internet::getInternalIP(), $this->getPort())); $this->network->registerInterface(new UPnPNetworkInterface($this->logger, Internet::getInternalIP(), $this->getPort()));
} }
if((bool) $this->configGroup->getProperty("settings.send-usage", true)){ if($this->configGroup->getPropertyBool("settings.send-usage", true)){
$this->sendUsageTicker = 6000; $this->sendUsageTicker = 6000;
$this->sendUsage(SendUsageTask::TYPE_OPEN); $this->sendUsage(SendUsageTask::TYPE_OPEN);
} }
@ -1396,7 +1396,7 @@ class Server{
} }
if($this->network instanceof Network){ if($this->network instanceof Network){
$this->network->getSessionManager()->close($this->configGroup->getProperty("settings.shutdown-message", "Server closed")); $this->network->getSessionManager()->close($this->configGroup->getPropertyString("settings.shutdown-message", "Server closed"));
} }
if($this->worldManager instanceof WorldManager){ if($this->worldManager instanceof WorldManager){
@ -1501,7 +1501,7 @@ class Server{
$this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.submit", [$dump->getPath()])); $this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.submit", [$dump->getPath()]));
if($this->configGroup->getProperty("auto-report.enabled", true) !== false){ if($this->configGroup->getPropertyBool("auto-report.enabled", true)){
$report = true; $report = true;
$stamp = $this->getDataPath() . "crashdumps/.last_crash"; $stamp = $this->getDataPath() . "crashdumps/.last_crash";
@ -1530,7 +1530,7 @@ class Server{
} }
if($report){ if($report){
$url = ((bool) $this->configGroup->getProperty("auto-report.use-https", true) ? "https" : "http") . "://" . $this->configGroup->getProperty("auto-report.host", "crash.pmmp.io") . "/submit/api"; $url = ($this->configGroup->getPropertyBool("auto-report.use-https", true) ? "https" : "http") . "://" . $this->configGroup->getPropertyString("auto-report.host", "crash.pmmp.io") . "/submit/api";
$postUrlError = "Unknown error"; $postUrlError = "Unknown error";
$reply = Internet::postURL($url, [ $reply = Internet::postURL($url, [
"report" => "yes", "report" => "yes",
@ -1616,7 +1616,7 @@ class Server{
} }
public function sendUsage(int $type = SendUsageTask::TYPE_STATUS) : void{ public function sendUsage(int $type = SendUsageTask::TYPE_STATUS) : void{
if((bool) $this->configGroup->getProperty("anonymous-statistics.enabled", true)){ if($this->configGroup->getPropertyBool("anonymous-statistics.enabled", true)){
$this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers)); $this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers));
} }
$this->uniquePlayers = []; $this->uniquePlayers = [];

View File

@ -65,6 +65,18 @@ final class ServerConfigGroup{
return $this->propertyCache[$variable] ?? $defaultValue; return $this->propertyCache[$variable] ?? $defaultValue;
} }
public function getPropertyBool(string $variable, bool $defaultValue) : bool{
return (bool) $this->getProperty($variable, $defaultValue);
}
public function getPropertyInt(string $variable, int $defaultValue) : int{
return (int) $this->getProperty($variable, $defaultValue);
}
public function getPropertyString(string $variable, string $defaultValue) : string{
return (string) $this->getProperty($variable, $defaultValue);
}
public function getConfigString(string $variable, string $defaultValue = "") : string{ public function getConfigString(string $variable, string $defaultValue = "") : string{
$v = getopt("", ["$variable::"]); $v = getopt("", ["$variable::"]);
if(isset($v[$variable])){ if(isset($v[$variable])){

View File

@ -131,7 +131,7 @@ class TimingsCommand extends VanillaCommand{
]; ];
fclose($fileTimings); fclose($fileTimings);
$host = $sender->getServer()->getConfigGroup()->getProperty("timings.host", "timings.pmmp.io"); $host = $sender->getServer()->getConfigGroup()->getPropertyString("timings.host", "timings.pmmp.io");
$sender->getServer()->getAsyncPool()->submitTask(new BulkCurlTask( $sender->getServer()->getAsyncPool()->submitTask(new BulkCurlTask(
[new BulkCurlTaskOperation( [new BulkCurlTaskOperation(

View File

@ -595,7 +595,7 @@ class NetworkSession{
} }
$this->logger->debug("Xbox Live authenticated: " . ($this->authenticated ? "YES" : "NO")); $this->logger->debug("Xbox Live authenticated: " . ($this->authenticated ? "YES" : "NO"));
$checkXUID = (bool) $this->server->getConfigGroup()->getProperty("player.verify-xuid", true); $checkXUID = $this->server->getConfigGroup()->getPropertyBool("player.verify-xuid", true);
$myXUID = $this->info instanceof XboxLivePlayerInfo ? $this->info->getXuid() : ""; $myXUID = $this->info instanceof XboxLivePlayerInfo ? $this->info->getXuid() : "";
$kickForXUIDMismatch = function(string $xuid) use ($checkXUID, $myXUID) : bool{ $kickForXUIDMismatch = function(string $xuid) use ($checkXUID, $myXUID) : bool{
if($checkXUID && $myXUID !== $xuid){ if($checkXUID && $myXUID !== $xuid){

View File

@ -103,7 +103,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
$threadToMainBuffer, $threadToMainBuffer,
new InternetAddress($this->server->getIp(), $this->server->getPort(), 4), new InternetAddress($this->server->getIp(), $this->server->getPort(), 4),
$this->rakServerId, $this->rakServerId,
(int) $this->server->getConfigGroup()->getProperty("network.max-mtu-size", 1492), $this->server->getConfigGroup()->getPropertyInt("network.max-mtu-size", 1492),
self::MCPE_RAKNET_PROTOCOL_VERSION, self::MCPE_RAKNET_PROTOCOL_VERSION,
$this->sleeper $this->sleeper
); );

View File

@ -77,7 +77,7 @@ final class QueryInfo{
public function __construct(Server $server){ public function __construct(Server $server){
$this->serverName = $server->getMotd(); $this->serverName = $server->getMotd();
$this->listPlugins = (bool) $server->getConfigGroup()->getProperty("settings.query-plugins", true); $this->listPlugins = $server->getConfigGroup()->getPropertyBool("settings.query-plugins", true);
$this->plugins = $server->getPluginManager()->getPlugins(); $this->plugins = $server->getPluginManager()->getPlugins();
$this->players = $server->getOnlinePlayers(); $this->players = $server->getOnlinePlayers();

View File

@ -281,8 +281,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$rootPermissions[DefaultPermissions::ROOT_OPERATOR] = true; $rootPermissions[DefaultPermissions::ROOT_OPERATOR] = true;
} }
$this->perm = new PermissibleBase($rootPermissions); $this->perm = new PermissibleBase($rootPermissions);
$this->chunksPerTick = (int) $this->server->getConfigGroup()->getProperty("chunk-sending.per-tick", 4); $this->chunksPerTick = $this->server->getConfigGroup()->getPropertyInt("chunk-sending.per-tick", 4);
$this->spawnThreshold = (int) (($this->server->getConfigGroup()->getProperty("chunk-sending.spawn-radius", 4) ** 2) * M_PI); $this->spawnThreshold = (int) (($this->server->getConfigGroup()->getPropertyInt("chunk-sending.spawn-radius", 4) ** 2) * M_PI);
$this->chunkSelector = new ChunkSelector(); $this->chunkSelector = new ChunkSelector();
$this->chunkLoader = new PlayerChunkLoader($spawnLocation); $this->chunkLoader = new PlayerChunkLoader($spawnLocation);
@ -502,7 +502,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
public function setViewDistance(int $distance) : void{ public function setViewDistance(int $distance) : void{
$this->viewDistance = $this->server->getAllowedViewDistance($distance); $this->viewDistance = $this->server->getAllowedViewDistance($distance);
$this->spawnThreshold = (int) (min($this->viewDistance, $this->server->getConfigGroup()->getProperty("chunk-sending.spawn-radius", 4)) ** 2 * M_PI); $this->spawnThreshold = (int) (min($this->viewDistance, $this->server->getConfigGroup()->getPropertyInt("chunk-sending.spawn-radius", 4)) ** 2 * M_PI);
$this->nextChunkOrderRun = 0; $this->nextChunkOrderRun = 0;
@ -806,7 +806,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->spawnToAll(); $this->spawnToAll();
if($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE) and $this->server->getConfigGroup()->getProperty("auto-updater.on-update.warn-ops", true)){ if($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE) and $this->server->getConfigGroup()->getPropertyBool("auto-updater.on-update.warn-ops", true)){
$this->server->getUpdater()->showPlayerUpdate($this); $this->server->getUpdater()->showPlayerUpdate($this);
} }

View File

@ -60,7 +60,7 @@ class SendUsageTask extends AsyncTask{
* @phpstan-param array<string, string> $playerList * @phpstan-param array<string, string> $playerList
*/ */
public function __construct(Server $server, int $type, array $playerList = []){ public function __construct(Server $server, int $type, array $playerList = []){
$endpoint = "http://" . $server->getConfigGroup()->getProperty("anonymous-statistics.host", "stats.pocketmine.net") . "/"; $endpoint = "http://" . $server->getConfigGroup()->getPropertyString("anonymous-statistics.host", "stats.pocketmine.net") . "/";
$data = []; $data = [];
$data["uniqueServerId"] = $server->getServerUniqueId()->toString(); $data["uniqueServerId"] = $server->getServerUniqueId()->toString();

View File

@ -55,7 +55,7 @@ class AutoUpdater{
$this->logger = new \PrefixedLogger($server->getLogger(), "Auto Updater"); $this->logger = new \PrefixedLogger($server->getLogger(), "Auto Updater");
$this->endpoint = "http://$endpoint/api/"; $this->endpoint = "http://$endpoint/api/";
if((bool) $server->getConfigGroup()->getProperty("auto-updater.enabled", true)){ if($server->getConfigGroup()->getPropertyBool("auto-updater.enabled", true)){
$this->doCheck(); $this->doCheck();
} }
} }
@ -72,7 +72,7 @@ class AutoUpdater{
$this->checkUpdate(); $this->checkUpdate();
if($this->hasUpdate()){ if($this->hasUpdate()){
(new UpdateNotifyEvent($this))->call(); (new UpdateNotifyEvent($this))->call();
if((bool) $this->server->getConfigGroup()->getProperty("auto-updater.on-update.warn-console", true)){ if($this->server->getConfigGroup()->getPropertyBool("auto-updater.on-update.warn-console", true)){
$this->showConsoleUpdate(); $this->showConsoleUpdate();
} }
}else{ }else{
@ -178,7 +178,7 @@ class AutoUpdater{
* Returns the channel used for update checking (stable, beta, dev) * Returns the channel used for update checking (stable, beta, dev)
*/ */
public function getChannel() : string{ public function getChannel() : string{
$channel = strtolower($this->server->getConfigGroup()->getProperty("auto-updater.preferred-channel", "stable")); $channel = strtolower($this->server->getConfigGroup()->getPropertyString("auto-updater.preferred-channel", "stable"));
if($channel !== "stable" and $channel !== "beta" and $channel !== "alpha" and $channel !== "development"){ if($channel !== "stable" and $channel !== "beta" and $channel !== "alpha" and $channel !== "development"){
$channel = "stable"; $channel = "stable";
} }

View File

@ -428,10 +428,10 @@ class World implements ChunkManager{
$this->time = $this->provider->getWorldData()->getTime(); $this->time = $this->provider->getWorldData()->getTime();
$cfg = $this->server->getConfigGroup(); $cfg = $this->server->getConfigGroup();
$this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $cfg->getProperty("chunk-ticking.tick-radius", 4))); $this->chunkTickRadius = min($this->server->getViewDistance(), max(1, $cfg->getPropertyInt("chunk-ticking.tick-radius", 4)));
$this->chunksPerTick = (int) $cfg->getProperty("chunk-ticking.per-tick", 40); $this->chunksPerTick = $cfg->getPropertyInt("chunk-ticking.per-tick", 40);
$this->tickedBlocksPerSubchunkPerTick = (int) $cfg->getProperty("chunk-ticking.blocks-per-subchunk-per-tick", self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK); $this->tickedBlocksPerSubchunkPerTick = $cfg->getPropertyInt("chunk-ticking.blocks-per-subchunk-per-tick", self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK);
$this->maxConcurrentChunkPopulationTasks = (int) $cfg->getProperty("chunk-generation.population-queue-size", 2); $this->maxConcurrentChunkPopulationTasks = $cfg->getPropertyInt("chunk-generation.population-queue-size", 2);
$dontTickBlocks = array_fill_keys($cfg->getProperty("chunk-ticking.disable-block-ticking", []), true); $dontTickBlocks = array_fill_keys($cfg->getProperty("chunk-ticking.disable-block-ticking", []), true);

View File

@ -15,29 +15,14 @@ parameters:
count: 1 count: 1
path: ../../../src/CrashDump.php path: ../../../src/CrashDump.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 7
path: ../../../src/MemoryManager.php
- -
message: "#^Cannot access offset 'type' on mixed\\.$#" message: "#^Cannot access offset 'type' on mixed\\.$#"
count: 1 count: 1
path: ../../../src/Server.php path: ../../../src/Server.php
-
message: "#^Cannot cast mixed to float\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 6
path: ../../../src/Server.php
- -
message: "#^Cannot cast mixed to string\\.$#" message: "#^Cannot cast mixed to string\\.$#"
count: 2 count: 1
path: ../../../src/Server.php path: ../../../src/Server.php
- -
@ -45,29 +30,14 @@ parameters:
count: 1 count: 1
path: ../../../src/Server.php path: ../../../src/Server.php
-
message: "#^Parameter \\#1 \\$reason of method pocketmine\\\\network\\\\NetworkSessionManager\\:\\:close\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Parameter \\#2 \\$defaultValue of method pocketmine\\\\ServerConfigGroup\\:\\:getConfigString\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^Parameter \\#2 \\$endpoint of class pocketmine\\\\updater\\\\AutoUpdater constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/Server.php
- -
message: "#^Cannot cast mixed to int\\.$#" message: "#^Cannot cast mixed to int\\.$#"
count: 1 count: 2
path: ../../../src/ServerConfigGroup.php path: ../../../src/ServerConfigGroup.php
- -
message: "#^Cannot cast mixed to string\\.$#" message: "#^Cannot cast mixed to string\\.$#"
count: 1 count: 2
path: ../../../src/ServerConfigGroup.php path: ../../../src/ServerConfigGroup.php
- -
@ -80,11 +50,6 @@ parameters:
count: 2 count: 2
path: ../../../src/VersionInfo.php path: ../../../src/VersionInfo.php
-
message: "#^Part \\$host \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
count: 1
path: ../../../src/command/defaults/TimingsCommand.php
- -
message: "#^Cannot cast mixed to float\\.$#" message: "#^Cannot cast mixed to float\\.$#"
count: 1 count: 1
@ -115,11 +80,6 @@ parameters:
count: 1 count: 1
path: ../../../src/network/mcpe/raklib/PthreadsChannelReader.php path: ../../../src/network/mcpe/raklib/PthreadsChannelReader.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../../src/network/mcpe/raklib/RakLibInterface.php
- -
message: "#^Parameter \\#1 \\$value of static method pocketmine\\\\permission\\\\PermissionParser\\:\\:defaultFromString\\(\\) expects bool\\|string, mixed given\\.$#" message: "#^Parameter \\#1 \\$value of static method pocketmine\\\\permission\\\\PermissionParser\\:\\:defaultFromString\\(\\) expects bool\\|string, mixed given\\.$#"
count: 1 count: 1
@ -130,11 +90,6 @@ parameters:
count: 1 count: 1
path: ../../../src/permission/PermissionParser.php path: ../../../src/permission/PermissionParser.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../../src/player/Player.php
- -
message: "#^Parameter \\#1 \\$description of method pocketmine\\\\command\\\\Command\\:\\:setDescription\\(\\) expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$description of method pocketmine\\\\command\\\\Command\\:\\:setDescription\\(\\) expects string, mixed given\\.$#"
count: 1 count: 1
@ -240,11 +195,6 @@ parameters:
count: 1 count: 1
path: ../../../src/timings/TimingsHandler.php path: ../../../src/timings/TimingsHandler.php
-
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
count: 1
path: ../../../src/updater/AutoUpdater.php
- -
message: "#^Parameter \\#2 \\$start of function substr expects int, mixed given\\.$#" message: "#^Parameter \\#2 \\$start of function substr expects int, mixed given\\.$#"
count: 1 count: 1
@ -285,11 +235,6 @@ parameters:
count: 1 count: 1
path: ../../../src/utils/Utils.php path: ../../../src/utils/Utils.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 4
path: ../../../src/world/World.php
- -
message: "#^Parameter \\#1 \\$keys of function array_fill_keys expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$keys of function array_fill_keys expects array, mixed given\\.$#"
count: 1 count: 1