mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 16:05:28 +00:00
VersionInfo: make static methods more constant-like
if we could have class constants declared at runtime, these would be constant.
This commit is contained in:
parent
5da90b9530
commit
a012e7ccc0
@ -60,7 +60,7 @@ function main(array $argv) : void{
|
|||||||
if(isset($argv[1])){
|
if(isset($argv[1])){
|
||||||
$currentVer = new VersionString($argv[1]);
|
$currentVer = new VersionString($argv[1]);
|
||||||
}else{
|
}else{
|
||||||
$currentVer = VersionInfo::getVersionObj();
|
$currentVer = VersionInfo::VERSION();
|
||||||
}
|
}
|
||||||
$nextVer = new VersionString(sprintf(
|
$nextVer = new VersionString(sprintf(
|
||||||
"%u.%u.%u",
|
"%u.%u.%u",
|
||||||
|
@ -328,7 +328,7 @@ class CrashDump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function generalData() : void{
|
private function generalData() : void{
|
||||||
$version = VersionInfo::getVersionObj();
|
$version = VersionInfo::VERSION();
|
||||||
$composerLibraries = [];
|
$composerLibraries = [];
|
||||||
foreach(InstalledVersions::getInstalledPackages() as $package){
|
foreach(InstalledVersions::getInstalledPackages() as $package){
|
||||||
$composerLibraries[$package] = sprintf(
|
$composerLibraries[$package] = sprintf(
|
||||||
@ -344,7 +344,7 @@ class CrashDump{
|
|||||||
$this->data["general"]["build"] = VersionInfo::BUILD_NUMBER;
|
$this->data["general"]["build"] = VersionInfo::BUILD_NUMBER;
|
||||||
$this->data["general"]["is_dev"] = VersionInfo::IS_DEVELOPMENT_BUILD;
|
$this->data["general"]["is_dev"] = VersionInfo::IS_DEVELOPMENT_BUILD;
|
||||||
$this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL;
|
$this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL;
|
||||||
$this->data["general"]["git"] = VersionInfo::getGitHash();
|
$this->data["general"]["git"] = VersionInfo::GIT_HASH();
|
||||||
$this->data["general"]["uname"] = php_uname("a");
|
$this->data["general"]["uname"] = php_uname("a");
|
||||||
$this->data["general"]["php"] = phpversion();
|
$this->data["general"]["php"] = phpversion();
|
||||||
$this->data["general"]["zend"] = zend_version();
|
$this->data["general"]["zend"] = zend_version();
|
||||||
@ -352,7 +352,7 @@ class CrashDump{
|
|||||||
$this->data["general"]["os"] = Utils::getOS();
|
$this->data["general"]["os"] = Utils::getOS();
|
||||||
$this->data["general"]["composer_libraries"] = $composerLibraries;
|
$this->data["general"]["composer_libraries"] = $composerLibraries;
|
||||||
$this->addLine($this->server->getName() . " version: " . $version->getFullVersion(true) . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "]");
|
$this->addLine($this->server->getName() . " version: " . $version->getFullVersion(true) . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "]");
|
||||||
$this->addLine("Git commit: " . VersionInfo::getGitHash());
|
$this->addLine("Git commit: " . VersionInfo::GIT_HASH());
|
||||||
$this->addLine("uname -a: " . php_uname("a"));
|
$this->addLine("uname -a: " . php_uname("a"));
|
||||||
$this->addLine("PHP Version: " . phpversion());
|
$this->addLine("PHP Version: " . phpversion());
|
||||||
$this->addLine("Zend version: " . zend_version());
|
$this->addLine("Zend version: " . zend_version());
|
||||||
|
@ -229,7 +229,7 @@ JIT_WARNING
|
|||||||
$composerGitHash = InstalledVersions::getReference('pocketmine/pocketmine-mp');
|
$composerGitHash = InstalledVersions::getReference('pocketmine/pocketmine-mp');
|
||||||
if($composerGitHash !== null){
|
if($composerGitHash !== null){
|
||||||
//we can't verify dependency versions if we were installed without using git
|
//we can't verify dependency versions if we were installed without using git
|
||||||
$currentGitHash = explode("-", VersionInfo::getGitHash())[0];
|
$currentGitHash = explode("-", VersionInfo::GIT_HASH())[0];
|
||||||
if($currentGitHash !== $composerGitHash){
|
if($currentGitHash !== $composerGitHash){
|
||||||
critical_error("Composer dependencies and/or autoloader are out of sync.");
|
critical_error("Composer dependencies and/or autoloader are out of sync.");
|
||||||
critical_error("- Current revision is $currentGitHash");
|
critical_error("- Current revision is $currentGitHash");
|
||||||
|
@ -260,7 +260,7 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPocketMineVersion() : string{
|
public function getPocketMineVersion() : string{
|
||||||
return VersionInfo::getVersionObj()->getFullVersion(true);
|
return VersionInfo::VERSION()->getFullVersion(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVersion() : string{
|
public function getVersion() : string{
|
||||||
@ -1452,7 +1452,7 @@ class Server{
|
|||||||
$report = false;
|
$report = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strrpos(VersionInfo::getGitHash(), "-dirty") !== false or VersionInfo::getGitHash() === str_repeat("00", 20)){
|
if(strrpos(VersionInfo::GIT_HASH(), "-dirty") !== false or VersionInfo::GIT_HASH() === str_repeat("00", 20)){
|
||||||
$this->logger->debug("Not sending crashdump due to locally modified");
|
$this->logger->debug("Not sending crashdump due to locally modified");
|
||||||
$report = false; //Don't send crashdumps for locally modified builds
|
$report = false; //Don't send crashdumps for locally modified builds
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ final class VersionInfo{
|
|||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
private static $gitHash = null;
|
private static $gitHash = null;
|
||||||
|
|
||||||
public static function getGitHash() : string{
|
public static function GIT_HASH() : string{
|
||||||
if(self::$gitHash === null){
|
if(self::$gitHash === null){
|
||||||
$gitHash = str_repeat("00", 20);
|
$gitHash = str_repeat("00", 20);
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ final class VersionInfo{
|
|||||||
/** @var VersionString|null */
|
/** @var VersionString|null */
|
||||||
private static $fullVersion = null;
|
private static $fullVersion = null;
|
||||||
|
|
||||||
public static function getVersionObj() : VersionString{
|
public static function VERSION() : VersionString{
|
||||||
if(self::$fullVersion === null){
|
if(self::$fullVersion === null){
|
||||||
self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER);
|
self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER);
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,8 @@ class VersionCommand extends VanillaCommand{
|
|||||||
VersionInfo::NAME
|
VersionInfo::NAME
|
||||||
));
|
));
|
||||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_version_serverSoftwareVersion(
|
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_version_serverSoftwareVersion(
|
||||||
VersionInfo::getVersionObj()->getFullVersion(),
|
VersionInfo::VERSION()->getFullVersion(),
|
||||||
VersionInfo::getGitHash()
|
VersionInfo::GIT_HASH()
|
||||||
));
|
));
|
||||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_version_minecraftVersion(
|
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_version_minecraftVersion(
|
||||||
ProtocolInfo::MINECRAFT_VERSION_NETWORK,
|
ProtocolInfo::MINECRAFT_VERSION_NETWORK,
|
||||||
|
@ -95,7 +95,7 @@ class PreSpawnPacketHandler extends PacketHandler{
|
|||||||
$pk->worldName = $this->server->getMotd();
|
$pk->worldName = $this->server->getMotd();
|
||||||
$pk->itemTable = GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(); //TODO: check if this is actually needed
|
$pk->itemTable = GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(); //TODO: check if this is actually needed
|
||||||
$pk->playerMovementSettings = new PlayerMovementSettings(PlayerMovementType::LEGACY, 0, false);
|
$pk->playerMovementSettings = new PlayerMovementSettings(PlayerMovementType::LEGACY, 0, false);
|
||||||
$pk->serverSoftwareVersion = sprintf("%s %s", VersionInfo::NAME, VersionInfo::getVersionObj()->getFullVersion(true));
|
$pk->serverSoftwareVersion = sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true));
|
||||||
$this->session->sendDataPacket($pk);
|
$this->session->sendDataPacket($pk);
|
||||||
|
|
||||||
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
||||||
|
@ -71,7 +71,7 @@ class SendUsageTask extends AsyncTask{
|
|||||||
case self::TYPE_OPEN:
|
case self::TYPE_OPEN:
|
||||||
$data["event"] = "open";
|
$data["event"] = "open";
|
||||||
|
|
||||||
$version = VersionInfo::getVersionObj();
|
$version = VersionInfo::VERSION();
|
||||||
|
|
||||||
$data["server"] = [
|
$data["server"] = [
|
||||||
"port" => $server->getPort(),
|
"port" => $server->getPort(),
|
||||||
|
@ -150,7 +150,7 @@ class AutoUpdater{
|
|||||||
if($this->updateInfo === null){
|
if($this->updateInfo === null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$currentVersion = VersionInfo::getVersionObj();
|
$currentVersion = VersionInfo::VERSION();
|
||||||
try{
|
try{
|
||||||
$newVersion = new VersionString($this->updateInfo->base_version, $this->updateInfo->is_dev, $this->updateInfo->build);
|
$newVersion = new VersionString($this->updateInfo->base_version, $this->updateInfo->is_dev, $this->updateInfo->build);
|
||||||
}catch(\InvalidArgumentException $e){
|
}catch(\InvalidArgumentException $e){
|
||||||
|
@ -209,7 +209,7 @@ class Internet{
|
|||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_CONNECTTIMEOUT_MS => (int) ($timeout * 1000),
|
CURLOPT_CONNECTTIMEOUT_MS => (int) ($timeout * 1000),
|
||||||
CURLOPT_TIMEOUT_MS => (int) ($timeout * 1000),
|
CURLOPT_TIMEOUT_MS => (int) ($timeout * 1000),
|
||||||
CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . VersionInfo::NAME . "/" . VersionInfo::getVersionObj()->getFullVersion(true)], $extraHeaders),
|
CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . VersionInfo::NAME . "/" . VersionInfo::VERSION()->getFullVersion(true)], $extraHeaders),
|
||||||
CURLOPT_HEADER => true
|
CURLOPT_HEADER => true
|
||||||
]);
|
]);
|
||||||
try{
|
try{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user