PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
VersionInfo.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine;
25
28use function is_array;
29use function is_int;
30use function str_repeat;
31
32final class VersionInfo{
33 public const NAME = "PocketMine-MP";
34 public const BASE_VERSION = "5.21.2";
35 public const IS_DEVELOPMENT_BUILD = true;
36 public const BUILD_CHANNEL = "stable";
37
47 public const WORLD_DATA_VERSION = 1;
51 public const TAG_WORLD_DATA_VERSION = "PMMPDataVersion"; //TAG_Long
52
53 private function __construct(){
54 //NOOP
55 }
56
57 private static ?string $gitHash = null;
58
59 public static function GIT_HASH() : string{
60 if(self::$gitHash === null){
61 $gitHash = str_repeat("00", 20);
62
63 if(\Phar::running(true) === ""){
64 $gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
65 }else{
66 $pharPath = \Phar::running(false);
67 $phar = \Phar::isValidPharFilename($pharPath) ? new \Phar($pharPath) : new \PharData($pharPath);
68 $meta = $phar->getMetadata();
69 if(isset($meta["git"])){
70 $gitHash = $meta["git"];
71 }
72 }
73
74 self::$gitHash = $gitHash;
75 }
76
77 return self::$gitHash;
78 }
79
80 private static ?int $buildNumber = null;
81
82 public static function BUILD_NUMBER() : int{
83 if(self::$buildNumber === null){
84 self::$buildNumber = 0;
85 if(\Phar::running(true) !== ""){
86 $pharPath = \Phar::running(false);
87 $phar = \Phar::isValidPharFilename($pharPath) ? new \Phar($pharPath) : new \PharData($pharPath);
88 $meta = $phar->getMetadata();
89 if(is_array($meta) && isset($meta["build"]) && is_int($meta["build"])){
90 self::$buildNumber = $meta["build"];
91 }
92 }
93 }
94
95 return self::$buildNumber;
96 }
97
98 private static ?VersionString $fullVersion = null;
99
100 public static function VERSION() : VersionString{
101 if(self::$fullVersion === null){
102 self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER());
103 }
104 return self::$fullVersion;
105 }
106}