Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2020-05-13 13:18:55 +01:00
commit 8766d4050c
8 changed files with 42 additions and 113 deletions

View File

@ -9,3 +9,10 @@ Plugin developers should **only** update their required API to this version if y
# 3.12.0
- Added support for Minecraft: Bedrock Edition 1.14.60
- Removed compatibility with 1.14.0-1.14.30
# 3.12.1
- Fixed parsing of single-line doc comments for event handlers, e.g. `/** @ignoreCancelled */` should now work correctly.
- The server will no longer crash on failure to load `level.dat` contents, but will gracefully shutdown instead without producing a crashdump.
- Fixed some bugs in login verification that could cause undefined behaviour.
- Fixed item-use behaviour when sneaking - sneaking and clicking a block with an empty hand, and sneaking and using an item, both now follow vanilla behaviour.
- `start.sh` will now work on platforms where `/bin/bash` is not available, as long as `/usr/bin/env` knows where bash is.

View File

@ -38,7 +38,7 @@
"ocramius/package-versions": "^1.5"
},
"require-dev": {
"phpstan/phpstan": "^0.12.22",
"phpstan/phpstan": "^0.12.25",
"irstea/phpunit-shim": "^8.5",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan-strict-rules": "^0.12.2"

12
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d3e3f1bbaf2a7dd3b214287ba2acdff8",
"content-hash": "c8ca5083f045613732190850991be6b1",
"packages": [
{
"name": "adhocore/json-comment",
@ -529,16 +529,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.23",
"version": "0.12.25",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "71e529efced79e055fa8318b692e7f7d03ea4e75"
"reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/71e529efced79e055fa8318b692e7f7d03ea4e75",
"reference": "71e529efced79e055fa8318b692e7f7d03ea4e75",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9619551d68b2d4c0d681a8df73f3c847c798ee64",
"reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64",
"shasum": ""
},
"require": {
@ -581,7 +581,7 @@
"type": "tidelift"
}
],
"time": "2020-05-05T12:55:44+00:00"
"time": "2020-05-10T20:36:16+00:00"
},
{
"name": "phpstan/phpstan-phpunit",

View File

@ -261,6 +261,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/** @var bool */
public $loggedIn = false;
/** @var bool */
private $seenLoginPacket = false;
/** @var bool */
private $resourcePacksDone = false;
@ -1816,9 +1818,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
public function handleLogin(LoginPacket $packet) : bool{
if($this->loggedIn){
if($this->seenLoginPacket){
return false;
}
$this->seenLoginPacket = true;
if($packet->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
if($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL){

View File

@ -33,6 +33,6 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){
const _VERSION_INFO_INCLUDED = true;
const NAME = "PocketMine-MP";
const BASE_VERSION = "3.12.1";
const BASE_VERSION = "3.12.2";
const IS_DEVELOPMENT_BUILD = true;
const BUILD_NUMBER = 0;

View File

@ -35,6 +35,7 @@ use function file_exists;
use function file_get_contents;
use function file_put_contents;
use function mkdir;
use function zlib_decode;
abstract class BaseLevelProvider implements LevelProvider{
/** @var string */
@ -53,8 +54,20 @@ abstract class BaseLevelProvider implements LevelProvider{
}
protected function loadLevelData() : void{
$compressedLevelData = @file_get_contents($this->getPath() . "level.dat");
if($compressedLevelData === false){
throw new LevelException("Failed to read level.dat (permission denied or doesn't exist)");
}
$rawLevelData = @zlib_decode($compressedLevelData);
if($rawLevelData === false){
throw new LevelException("Failed to decompress level.dat contents (probably corrupted)");
}
$nbt = new BigEndianNBTStream();
$levelData = $nbt->readCompressed(file_get_contents($this->getPath() . "level.dat"));
try{
$levelData = $nbt->read($rawLevelData);
}catch(\UnexpectedValueException $e){
throw new LevelException("Failed to decode level.dat (" . $e->getMessage() . ")", 0, $e);
}
if(!($levelData instanceof CompoundTag) or !$levelData->hasTag("Data", CompoundTag::class)){
throw new LevelException("Invalid level.dat");

View File

@ -27,9 +27,9 @@ use pocketmine\network\mcpe\protocol\LoginPacket;
use pocketmine\Player;
use pocketmine\scheduler\AsyncTask;
use pocketmine\Server;
use function assert;
use function base64_decode;
use function chr;
use function count;
use function explode;
use function json_decode;
use function ltrim;
@ -94,7 +94,11 @@ class VerifyLoginTask extends AsyncTask{
* @throws VerifyLoginException if errors are encountered
*/
private function validateToken(string $jwt, ?string &$currentPublicKey, bool $first = false) : void{
[$headB64, $payloadB64, $sigB64] = explode('.', $jwt);
$rawParts = explode('.', $jwt);
if(count($rawParts) !== 3){
throw new VerifyLoginException("Wrong number of JWT parts, expected 3, got " . count($rawParts));
}
[$headB64, $payloadB64, $sigB64] = $rawParts;
$headers = json_decode(base64_decode(strtr($headB64, '-_', '+/'), true), true);
@ -111,7 +115,9 @@ class VerifyLoginTask extends AsyncTask{
//OpenSSL wants a DER-encoded signature, so we extract R and S from the plain signature and crudely serialize it.
assert(strlen($plainSignature) === 96);
if(strlen($plainSignature) !== 96){
throw new VerifyLoginException("Wrong signature length, expected 96, got " . strlen($plainSignature));
}
[$rString, $sString] = str_split($plainSignature, 48);

View File

@ -15,26 +15,6 @@ parameters:
count: 3
path: ../../../src/pocketmine/command/CommandReader.php
-
message: "#^Default value of the parameter \\#4 \\$min \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#5 \\$max \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getRelativeDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#3 \\$min \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Default value of the parameter \\#4 \\$max \\(int\\) of method pocketmine\\\\command\\\\defaults\\\\VanillaCommand\\:\\:getDouble\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#"
count: 1
@ -45,86 +25,6 @@ parameters:
count: 2
path: ../../../src/pocketmine/level/format/io/region/RegionLoader.php
-
message: "#^Default value of the parameter \\#4 \\$expansion \\(int\\) of method pocketmine\\\\level\\\\generator\\\\noise\\\\Perlin\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/noise/Perlin.php
-
message: "#^Default value of the parameter \\#4 \\$expansion \\(int\\) of method pocketmine\\\\level\\\\generator\\\\noise\\\\Simplex\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/noise/Simplex.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\AnvilBreakSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/AnvilBreakSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\AnvilFallSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/AnvilFallSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\AnvilUseSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/AnvilUseSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\BlazeShootSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/BlazeShootSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\ClickSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/ClickSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\DoorBumpSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/DoorBumpSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\DoorCrashSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/DoorCrashSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\DoorSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/DoorSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\FizzSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/FizzSound.php
-
message: "#^Default value of the parameter \\#3 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\GenericSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/GenericSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\GhastShootSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/GhastShootSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\GhastSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/GhastSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\LaunchSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/LaunchSound.php
-
message: "#^Default value of the parameter \\#2 \\$pitch \\(int\\) of method pocketmine\\\\level\\\\sound\\\\PopSound\\:\\:__construct\\(\\) is incompatible with type float\\.$#"
count: 1
path: ../../../src/pocketmine/level/sound/PopSound.php
-
message: "#^Call to function method_exists\\(\\) with pocketmine\\\\network\\\\mcpe\\\\CachedEncapsulatedPacket and '__toString' will always evaluate to true\\.$#"
count: 1