mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Merge pull request #2438 from PocketMine/new-version-format
New release version format
This commit is contained in:
commit
7be4e2fa81
@ -70,7 +70,7 @@ namespace pocketmine {
|
|||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\wizard\Installer;
|
use pocketmine\wizard\Installer;
|
||||||
|
|
||||||
const VERSION = "Alpha_1.4dev";
|
const VERSION = "1.4dev";
|
||||||
const API_VERSION = "1.10.0";
|
const API_VERSION = "1.10.0";
|
||||||
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
|
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
|
||||||
const MINECRAFT_VERSION = "v0.10.4 alpha";
|
const MINECRAFT_VERSION = "v0.10.4 alpha";
|
||||||
|
@ -26,30 +26,18 @@ namespace pocketmine\utils;
|
|||||||
* Manages PocketMine-MP version strings, and compares them
|
* Manages PocketMine-MP version strings, and compares them
|
||||||
*/
|
*/
|
||||||
class VersionString{
|
class VersionString{
|
||||||
public static $stageOrder = [
|
|
||||||
"alpha" => 0,
|
|
||||||
"a" => 0,
|
|
||||||
"beta" => 1,
|
|
||||||
"b" => 1,
|
|
||||||
"final" => 2,
|
|
||||||
"f" => 2,
|
|
||||||
];
|
|
||||||
private $stage;
|
|
||||||
private $major;
|
private $major;
|
||||||
private $build;
|
private $build;
|
||||||
private $minor;
|
private $minor;
|
||||||
private $development = false;
|
private $development = false;
|
||||||
private $generation;
|
|
||||||
|
|
||||||
public function __construct($version = \pocketmine\VERSION){
|
public function __construct($version = \pocketmine\VERSION){
|
||||||
if(is_int($version)){
|
if(is_int($version)){
|
||||||
$this->minor = $version & 0x1F;
|
$this->minor = $version & 0x1F;
|
||||||
$this->major = ($version >> 5) & 0x0F;
|
$this->major = ($version >> 5) & 0x0F;
|
||||||
$this->generation = ($version >> 9) & 0x0F;
|
$this->generation = ($version >> 9) & 0x0F;
|
||||||
$this->stage = array_search(($version >> 13) & 0x0F, VersionString::$stageOrder, true);
|
|
||||||
}else{
|
}else{
|
||||||
$version = preg_split("/([A-Za-z]*)[ _\\-]([0-9]*)\\.([0-9]*)\\.{0,1}([0-9]*)(dev|)(-[\\0-9]{1,}|)/", $version, -1, PREG_SPLIT_DELIM_CAPTURE);
|
$version = preg_split("/([A-Za-z]*)[ _\\-]?([0-9]*)\\.([0-9]*)\\.{0,1}([0-9]*)(dev|)(-[\\0-9]{1,}|)/", $version, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||||
$this->stage = strtolower($version[1]); //0-15
|
|
||||||
$this->generation = (int) $version[2]; //0-15
|
$this->generation = (int) $version[2]; //0-15
|
||||||
$this->major = (int) $version[3]; //0-15
|
$this->major = (int) $version[3]; //0-15
|
||||||
$this->minor = (int) $version[4]; //0-31
|
$this->minor = (int) $version[4]; //0-31
|
||||||
@ -63,11 +51,14 @@ class VersionString{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getNumber(){
|
public function getNumber(){
|
||||||
return (int) (VersionString::$stageOrder[$this->stage] << 13) + ($this->generation << 9) + ($this->major << 5) + $this->minor;
|
return (int) (($this->generation << 9) + ($this->major << 5) + $this->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public function getStage(){
|
public function getStage(){
|
||||||
return $this->stage;
|
return "final";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGeneration(){
|
public function getGeneration(){
|
||||||
@ -95,7 +86,7 @@ class VersionString{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get($build = false){
|
public function get($build = false){
|
||||||
return ucfirst($this->stage) . "_" . $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
|
return $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(){
|
public function __toString(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user