PocketMine-MP 5.36.1 git-eaa7c4834c8fe2f379d24e7f0ee6cc63cfb18ccc
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.36.1";
35 public const IS_DEVELOPMENT_BUILD = true;
36 public const BUILD_CHANNEL = "stable";
37 public const GITHUB_URL = "https://github.com/pmmp/PocketMine-MP";
38
48 public const WORLD_DATA_VERSION = 1;
52 public const TAG_WORLD_DATA_VERSION = "PMMPDataVersion"; //TAG_Long
53
54 private function __construct(){
55 //NOOP
56 }
57
58 private static ?string $gitHash = null;
59
60 public static function GIT_HASH() : string{
61 if(self::$gitHash === null){
62 $gitHash = str_repeat("00", 20);
63
64 if(\Phar::running(true) === ""){
65 $gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
66 }else{
67 $pharPath = \Phar::running(false);
68 $phar = \Phar::isValidPharFilename($pharPath) ? new \Phar($pharPath) : new \PharData($pharPath);
69 $meta = $phar->getMetadata();
70 if(isset($meta["git"])){
71 $gitHash = $meta["git"];
72 }
73 }
74
75 self::$gitHash = $gitHash;
76 }
77
78 return self::$gitHash;
79 }
80
81 private static ?int $buildNumber = null;
82
83 public static function BUILD_NUMBER() : int{
84 if(self::$buildNumber === null){
85 self::$buildNumber = 0;
86 if(\Phar::running(true) !== ""){
87 $pharPath = \Phar::running(false);
88 $phar = \Phar::isValidPharFilename($pharPath) ? new \Phar($pharPath) : new \PharData($pharPath);
89 $meta = $phar->getMetadata();
90 if(is_array($meta) && isset($meta["build"]) && is_int($meta["build"])){
91 self::$buildNumber = $meta["build"];
92 }
93 }
94 }
95
96 return self::$buildNumber;
97 }
98
99 private static ?VersionString $fullVersion = null;
100
101 public static function VERSION() : VersionString{
102 if(self::$fullVersion === null){
103 self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER());
104 }
105 return self::$fullVersion;
106 }
107}