Merge branch 'release/3.1'

This commit is contained in:
Dylan K. Taylor 2018-07-05 17:43:19 +01:00
commit 4ccbb8b21a
3 changed files with 85 additions and 70 deletions

View File

@ -53,83 +53,89 @@ namespace pocketmine {
* Enjoy it as much as I did writing it. I don't want to do it again. * Enjoy it as much as I did writing it. I don't want to do it again.
*/ */
if(version_compare(MIN_PHP_VERSION, PHP_VERSION) > 0){ /**
critical_error(\pocketmine\NAME . " requires PHP >= " . MIN_PHP_VERSION . ", but you have PHP " . PHP_VERSION . "."); * @return string[]
critical_error("Please refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html."); */
exit(1); function check_platform_dependencies(){
} if(version_compare(MIN_PHP_VERSION, PHP_VERSION) > 0){
//If PHP version isn't high enough, anything below might break, so don't bother checking it.
if(PHP_INT_SIZE < 8){ return [
critical_error("Running " . \pocketmine\NAME . " with 32-bit systems/PHP is no longer supported."); \pocketmine\NAME . " requires PHP >= " . MIN_PHP_VERSION . ", but you have PHP " . PHP_VERSION . "."
critical_error("Please upgrade to a 64-bit system, or use a 64-bit PHP binary if this is a 64-bit system."); ];
critical_error("Please refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
exit(1);
}
/* Dependencies check */
$errors = 0;
if(php_sapi_name() !== "cli"){
critical_error("You must run " . \pocketmine\NAME . " using the CLI.");
++$errors;
}
$extensions = [
"bcmath" => "BC Math",
"curl" => "cURL",
"ctype" => "ctype",
"date" => "Date",
"hash" => "Hash",
"json" => "JSON",
"mbstring" => "Multibyte String",
"openssl" => "OpenSSL",
"pcre" => "PCRE",
"phar" => "Phar",
"pthreads" => "pthreads",
"reflection" => "Reflection",
"sockets" => "Sockets",
"spl" => "SPL",
"yaml" => "YAML",
"zip" => "Zip",
"zlib" => "Zlib"
];
foreach($extensions as $ext => $name){
if(!extension_loaded($ext)){
critical_error("Unable to find the $name ($ext) extension.");
++$errors;
} }
}
if(extension_loaded("pthreads")){ $messages = [];
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){ if(PHP_INT_SIZE < 8){
$pthreads_version = "0.$pthreads_version"; $messages[] = "Running " . \pocketmine\NAME . " with 32-bit systems/PHP is no longer supported. Please upgrade to a 64-bit system, or use a 64-bit PHP binary if this is a 64-bit system.";
} }
if(version_compare($pthreads_version, "3.1.7dev") < 0){
critical_error("pthreads >= 3.1.7dev is required, while you have $pthreads_version."); if(php_sapi_name() !== "cli"){
++$errors; $messages[] = "You must run " . \pocketmine\NAME . " using the CLI.";
} }
}
if(extension_loaded("leveldb")){ $extensions = [
$leveldb_version = phpversion("leveldb"); "bcmath" => "BC Math",
if(version_compare($leveldb_version, "0.2.1") < 0){ "curl" => "cURL",
critical_error("php-leveldb >= 0.2.1 is required, while you have $leveldb_version"); "ctype" => "ctype",
++$errors; "date" => "Date",
"hash" => "Hash",
"json" => "JSON",
"mbstring" => "Multibyte String",
"openssl" => "OpenSSL",
"pcre" => "PCRE",
"phar" => "Phar",
"pthreads" => "pthreads",
"reflection" => "Reflection",
"sockets" => "Sockets",
"spl" => "SPL",
"yaml" => "YAML",
"zip" => "Zip",
"zlib" => "Zlib"
];
foreach($extensions as $ext => $name){
if(!extension_loaded($ext)){
$messages[] = "Unable to find the $name ($ext) extension.";
}
} }
if(extension_loaded("pthreads")){
$pthreads_version = phpversion("pthreads");
if(substr_count($pthreads_version, ".") < 2){
$pthreads_version = "0.$pthreads_version";
}
if(version_compare($pthreads_version, "3.1.7dev") < 0){
$messages[] = "pthreads >= 3.1.7dev is required, while you have $pthreads_version.";
}
}
if(extension_loaded("leveldb")){
$leveldb_version = phpversion("leveldb");
if(version_compare($leveldb_version, "0.2.1") < 0){
$messages[] = "php-leveldb >= 0.2.1 is required, while you have $leveldb_version.";
}
}
if(extension_loaded("pocketmine")){
$messages[] = "The native PocketMine extension is no longer supported.";
}
return $messages;
} }
if(extension_loaded("pocketmine")){ if(!empty($messages = check_platform_dependencies())){
critical_error("The native PocketMine extension is no longer supported."); echo PHP_EOL;
++$errors; $binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
} critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
foreach($messages as $m){
if($errors > 0){ echo " - $m" . PHP_EOL;
}
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html."); critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
echo PHP_EOL;
exit(1); exit(1);
} }
unset($messages);
error_reporting(-1); error_reporting(-1);

View File

@ -64,7 +64,12 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
} }
public function setItem(int $index, Item $item, bool $send = true) : bool{ public function setItem(int $index, Item $item, bool $send = true) : bool{
return $index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send); $old = $this->getItem($index);
if($index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send)){
$this->onSlotChange($index, $old, $send);
return true;
}
return false;
} }
public function getContents(bool $includeEmpty = false) : array{ public function getContents(bool $includeEmpty = false) : array{

View File

@ -113,10 +113,14 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
$pair->checkPairing(); $pair->checkPairing();
} }
if($this->doubleInventory === null){ if($this->doubleInventory === null){
if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly if($pair->doubleInventory !== null){
$this->doubleInventory = new DoubleChestInventory($pair, $this); $this->doubleInventory = $pair->doubleInventory;
}else{ }else{
$this->doubleInventory = new DoubleChestInventory($this, $pair); if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly
$this->doubleInventory = new DoubleChestInventory($pair, $this);
}else{
$this->doubleInventory = new DoubleChestInventory($this, $pair);
}
} }
} }
}else{ }else{