mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Added custom settings, update notification
This commit is contained in:
@ -36,7 +36,7 @@ class VersionString{
|
||||
);
|
||||
private $stage;
|
||||
private $major;
|
||||
private $release;
|
||||
private $build;
|
||||
private $minor;
|
||||
private $development = false;
|
||||
private $generation;
|
||||
@ -48,12 +48,17 @@ class VersionString{
|
||||
$this->generation = ($version >> 9) & 0x0F;
|
||||
$this->stage = array_search(($version >> 13) & 0x0F, VersionString::$stageOrder, true);
|
||||
}else{
|
||||
$version = preg_split("/([A-Za-z]*)[ _\-]([0-9]*)\.([0-9]*)\.{0,1}([0-9]*)(dev|)/", $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->major = (int) $version[3]; //0-15
|
||||
$this->minor = (int) $version[4]; //0-31
|
||||
$this->development = $version[5] === "dev" ? true : false;
|
||||
if($version[6] !== ""){
|
||||
$this->build = intval(substr($version[6], 1));
|
||||
}else{
|
||||
$this->build = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,12 +86,16 @@ class VersionString{
|
||||
return $this->generation . "." . $this->major . "." . $this->minor;
|
||||
}
|
||||
|
||||
public function getBuild(){
|
||||
return $this->build;
|
||||
}
|
||||
|
||||
public function isDev(){
|
||||
return $this->development === true;
|
||||
}
|
||||
|
||||
public function get(){
|
||||
return ucfirst($this->stage) . "_" . $this->getRelease() . ($this->development === true ? "dev" : "");
|
||||
public function get($build = false){
|
||||
return ucfirst($this->stage) . "_" . $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
@ -106,6 +115,10 @@ class VersionString{
|
||||
return -1; //Target is older
|
||||
}elseif($number < $tNumber){
|
||||
return 1; //Target is newer
|
||||
}elseif($target->getBuild() > $this->getBuild()){
|
||||
return 1;
|
||||
}elseif($target->getBuild() > $this->getBuild()){
|
||||
return -1;
|
||||
}else{
|
||||
return 0; //Same version
|
||||
}
|
||||
|
Reference in New Issue
Block a user