Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor 2021-03-07 20:15:11 +00:00
commit c1e5dd2a4e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
11 changed files with 113 additions and 117 deletions

View File

@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
image: [ubuntu-20.04]
php: [7.4.15]
php: [7.4.16]
steps:
- uses: actions/checkout@v2 #needed for build.sh
@ -37,7 +37,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.4.15]
php: [7.4.16]
steps:
- uses: actions/checkout@v2
@ -87,7 +87,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.4.15]
php: [7.4.16]
steps:
- uses: actions/checkout@v2
@ -137,7 +137,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.4.15]
php: [7.4.16]
steps:
- uses: actions/checkout@v2

View File

@ -49,7 +49,7 @@
"respect/validation": "^2.0"
},
"require-dev": {
"phpstan/phpstan": "0.12.76",
"phpstan/phpstan": "0.12.80",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "^9.2"

80
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": "e4cfe198391e336599789b5df4cabfd3",
"content-hash": "5aa48d296aa8e42c1d52fdce2cde29a7",
"packages": [
{
"name": "adhocore/json-comment",
@ -679,16 +679,16 @@
},
{
"name": "pocketmine/snooze",
"version": "0.1.4",
"version": "0.1.5",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Snooze.git",
"reference": "382ab149f01ecca0a57f999ff5d7fc9e271c3268"
"reference": "70b5e7937a06878dd321a3182ceb76d56298f2cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/382ab149f01ecca0a57f999ff5d7fc9e271c3268",
"reference": "382ab149f01ecca0a57f999ff5d7fc9e271c3268",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/70b5e7937a06878dd321a3182ceb76d56298f2cd",
"reference": "70b5e7937a06878dd321a3182ceb76d56298f2cd",
"shasum": ""
},
"require": {
@ -697,7 +697,7 @@
},
"require-dev": {
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.67",
"phpstan/phpstan": "0.12.76",
"phpstan/phpstan-strict-rules": "^0.12.4"
},
"type": "library",
@ -713,9 +713,9 @@
"description": "Thread notification management library for code using the pthreads extension",
"support": {
"issues": "https://github.com/pmmp/Snooze/issues",
"source": "https://github.com/pmmp/Snooze/tree/0.1.4"
"source": "https://github.com/pmmp/Snooze/tree/0.1.5"
},
"time": "2021-01-15T14:44:16+00:00"
"time": "2021-02-22T16:16:12+00:00"
},
{
"name": "pocketmine/spl",
@ -921,16 +921,16 @@
},
{
"name": "sokil/php-isocodes",
"version": "3.3.3",
"version": "3.3.5",
"source": {
"type": "git",
"url": "https://github.com/sokil/php-isocodes.git",
"reference": "d05d170a554f61ba793e31a78d2b4b3aaa80907f"
"reference": "1b3d6911c61a8e929f30367ac7fac5b9f48f4d58"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sokil/php-isocodes/zipball/d05d170a554f61ba793e31a78d2b4b3aaa80907f",
"reference": "d05d170a554f61ba793e31a78d2b4b3aaa80907f",
"url": "https://api.github.com/repos/sokil/php-isocodes/zipball/1b3d6911c61a8e929f30367ac7fac5b9f48f4d58",
"reference": "1b3d6911c61a8e929f30367ac7fac5b9f48f4d58",
"shasum": ""
},
"require": {
@ -972,22 +972,22 @@
"description": "ISO country, subdivision, language, currency and script definitions and their translations. Based on pythons pycountry and Debian's iso-codes.",
"support": {
"issues": "https://github.com/sokil/php-isocodes/issues",
"source": "https://github.com/sokil/php-isocodes/tree/3.3.3"
"source": "https://github.com/sokil/php-isocodes/tree/3.3.5"
},
"time": "2021-02-02T06:42:33+00:00"
"time": "2021-03-02T08:18:52+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.22.0",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13"
"reference": "5232de97ee3b75b0360528dae24e73db49566ab1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13",
"reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1",
"reference": "5232de97ee3b75b0360528dae24e73db49566ab1",
"shasum": ""
},
"require": {
@ -1038,7 +1038,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.0"
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.1"
},
"funding": [
{
@ -1054,7 +1054,7 @@
"type": "tidelift"
}
],
"time": "2021-01-07T16:49:33+00:00"
"time": "2021-01-22T09:19:47+00:00"
}
],
"packages-dev": [
@ -1303,16 +1303,16 @@
},
{
"name": "phar-io/version",
"version": "3.0.4",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451"
"reference": "bae7c545bef187884426f042434e561ab1ddb182"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451",
"url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
"reference": "bae7c545bef187884426f042434e561ab1ddb182",
"shasum": ""
},
"require": {
@ -1348,9 +1348,9 @@
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/3.0.4"
"source": "https://github.com/phar-io/version/tree/3.1.0"
},
"time": "2020-12-13T23:18:30+00:00"
"time": "2021-02-23T14:00:09+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@ -1579,16 +1579,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.76",
"version": "0.12.80",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "7aaaf9a759a29795e8f46d48041af1c1f1b23d38"
"reference": "c6a1b17f22ecf708d434d6bee05092647ec7e686"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7aaaf9a759a29795e8f46d48041af1c1f1b23d38",
"reference": "7aaaf9a759a29795e8f46d48041af1c1f1b23d38",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6a1b17f22ecf708d434d6bee05092647ec7e686",
"reference": "c6a1b17f22ecf708d434d6bee05092647ec7e686",
"shasum": ""
},
"require": {
@ -1619,7 +1619,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.76"
"source": "https://github.com/phpstan/phpstan/tree/0.12.80"
},
"funding": [
{
@ -1635,20 +1635,20 @@
"type": "tidelift"
}
],
"time": "2021-02-13T11:47:44+00:00"
"time": "2021-02-28T20:22:43+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "0.12.17",
"version": "0.12.18",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "432575b41cf2d4f44e460234acaf56119ed97d36"
"reference": "ab44aec7cfb5cb267b8bc30a8caea86dd50d1f72"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/432575b41cf2d4f44e460234acaf56119ed97d36",
"reference": "432575b41cf2d4f44e460234acaf56119ed97d36",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/ab44aec7cfb5cb267b8bc30a8caea86dd50d1f72",
"reference": "ab44aec7cfb5cb267b8bc30a8caea86dd50d1f72",
"shasum": ""
},
"require": {
@ -1688,9 +1688,9 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.17"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.18"
},
"time": "2020-12-13T12:12:51+00:00"
"time": "2021-03-06T11:51:27+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
@ -3130,7 +3130,7 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.22.0",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@ -3189,7 +3189,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1"
},
"funding": [
{

View File

@ -189,9 +189,16 @@ class CrashDump{
if($this->server->getConfigGroup()->getProperty("auto-report.send-settings", true) !== false){
$this->data["parameters"] = (array) $argv;
$this->data["server.properties"] = @file_get_contents($this->server->getDataPath() . "server.properties");
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $this->data["server.properties"]);
$this->data["pocketmine.yml"] = @file_get_contents($this->server->getDataPath() . "pocketmine.yml");
if(($serverDotProperties = @file_get_contents($this->server->getDataPath() . "server.properties")) !== false){
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $serverDotProperties);
}else{
$this->data["server.properties"] = $serverDotProperties;
}
if(($pocketmineDotYml = @file_get_contents($this->server->getDataPath() . "pocketmine.yml")) !== false){
$this->data["pocketmine.yml"] = $pocketmineDotYml;
}else{
$this->data["pocketmine.yml"] = "";
}
}else{
$this->data["pocketmine.yml"] = "";
$this->data["server.properties"] = "";

View File

@ -903,8 +903,7 @@ class Server{
$this->onlineMode = $this->configGroup->getConfigBool("xbox-auth", true);
if($this->onlineMode){
$this->logger->notice($this->getLanguage()->translateString("pocketmine.server.auth.enabled"));
$this->logger->notice($this->getLanguage()->translateString("pocketmine.server.authProperty.enabled"));
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.auth.enabled"));
}else{
$this->logger->warning($this->getLanguage()->translateString("pocketmine.server.auth.disabled"));
$this->logger->warning($this->getLanguage()->translateString("pocketmine.server.authWarning"));

View File

@ -472,6 +472,7 @@ abstract class Liquid extends Transparent{
return $isOptimalFlowDirection;
}
/** @phpstan-impure */
private function getSmallestFlowDecay(Block $block, int $decay) : int{
if(!($block instanceof Liquid) or !$block->isSameType($this)){
return $decay;

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\network;
use pocketmine\event\player\PlayerDuplicateLoginEvent;
use pocketmine\network\mcpe\NetworkSession;
use function count;
use function spl_object_id;
@ -59,33 +58,6 @@ class NetworkSessionManager{
$this->updateSessions[spl_object_id($session)] = $session;
}
/**
* Checks whether this network session is a duplicate of an already-connected session (same player connecting from
* 2 locations).
*
* @return bool if the network session is still connected.
*/
public function kickDuplicates(NetworkSession $connectingSession) : bool{
foreach($this->sessions as $existingSession){
if($existingSession === $connectingSession){
continue;
}
$info = $existingSession->getPlayerInfo();
if($info !== null and ($info->getUsername() === $connectingSession->getPlayerInfo()->getUsername() or $info->getUuid()->equals($connectingSession->getPlayerInfo()->getUuid()))){
$ev = new PlayerDuplicateLoginEvent($connectingSession, $existingSession);
$ev->call();
if($ev->isCancelled()){
$connectingSession->disconnect($ev->getDisconnectMessage());
return false;
}
$existingSession->disconnect($ev->getDisconnectMessage());
}
}
return true;
}
/**
* Returns the number of known connected sessions.
*/
@ -93,6 +65,9 @@ class NetworkSessionManager{
return count($this->sessions);
}
/** @return NetworkSession[] */
public function getSessions() : array{ return $this->sessions; }
/**
* Updates all sessions which need it.
*/

View File

@ -30,6 +30,7 @@ use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\Entity;
use pocketmine\entity\Human;
use pocketmine\entity\Living;
use pocketmine\event\player\PlayerDuplicateLoginEvent;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\event\server\DataPacketSendEvent;
use pocketmine\form\Form;
@ -607,43 +608,68 @@ class NetworkSession{
}
$this->logger->debug("Xbox Live authenticated: " . ($this->authenticated ? "YES" : "NO"));
//TODO: make player data loading async
//TODO: we shouldn't be loading player data here at all, but right now we don't have any choice :(
$this->cachedOfflinePlayerData = $this->server->getOfflinePlayerData($this->info->getUsername());
if((bool) $this->server->getConfigGroup()->getProperty("player.verify-xuid", true)){
$recordedXUID = $this->cachedOfflinePlayerData !== null ? $this->cachedOfflinePlayerData->getTag("LastKnownXUID") : null;
if(!($recordedXUID instanceof StringTag)){
$this->logger->debug("No previous XUID recorded, no choice but to trust this player");
}elseif(($this->info instanceof XboxLivePlayerInfo ? $this->info->getXuid() : "") !== $recordedXUID->getValue()){
$checkXUID = (bool) $this->server->getConfigGroup()->getProperty("player.verify-xuid", true);
$myXUID = $this->info instanceof XboxLivePlayerInfo ? $this->info->getXuid() : "";
$kickForXUIDMismatch = function(string $xuid) use ($checkXUID, $myXUID) : bool{
if($checkXUID && $myXUID !== $xuid){
//TODO: Longer term, we should be identifying playerdata using something more reliable, like XUID or UUID.
//However, that would be a very disruptive change, so this will serve as a stopgap for now.
//Side note: this will also prevent offline players hijacking XBL playerdata on online servers, since their
//XUID will always be empty.
$this->disconnect("XUID does not match (possible impersonation attempt)");
return;
}else{
return true;
}
return false;
};
foreach($this->manager->getSessions() as $existingSession){
if($existingSession === $this){
continue;
}
$info = $existingSession->getPlayerInfo();
if($info !== null and ($info->getUsername() === $this->info->getUsername() or $info->getUuid()->equals($this->info->getUuid()))){
if($kickForXUIDMismatch($info instanceof XboxLivePlayerInfo ? $info->getXuid() : "")){
return;
}
$ev = new PlayerDuplicateLoginEvent($this, $existingSession);
$ev->call();
if($ev->isCancelled()){
$this->disconnect($ev->getDisconnectMessage());
return;
}
$existingSession->disconnect($ev->getDisconnectMessage());
}
}
//TODO: make player data loading async
//TODO: we shouldn't be loading player data here at all, but right now we don't have any choice :(
$this->cachedOfflinePlayerData = $this->server->getOfflinePlayerData($this->info->getUsername());
if($checkXUID){
$recordedXUID = $this->cachedOfflinePlayerData !== null ? $this->cachedOfflinePlayerData->getTag("LastKnownXUID") : null;
if(!($recordedXUID instanceof StringTag)){
$this->logger->debug("No previous XUID recorded, no choice but to trust this player");
}elseif(!$kickForXUIDMismatch($recordedXUID->getValue())){
$this->logger->debug("XUID match");
}
}
if($this->manager->kickDuplicates($this)){
if(EncryptionContext::$ENABLED){
$this->server->getAsyncPool()->submitTask(new PrepareEncryptionTask($clientPubKey, function(string $encryptionKey, string $handshakeJwt) : void{
if(!$this->connected){
return;
}
$this->sendDataPacket(ServerToClientHandshakePacket::create($handshakeJwt), true); //make sure this gets sent before encryption is enabled
if(EncryptionContext::$ENABLED){
$this->server->getAsyncPool()->submitTask(new PrepareEncryptionTask($clientPubKey, function(string $encryptionKey, string $handshakeJwt) : void{
if(!$this->connected){
return;
}
$this->sendDataPacket(ServerToClientHandshakePacket::create($handshakeJwt), true); //make sure this gets sent before encryption is enabled
$this->cipher = new EncryptionContext($encryptionKey);
$this->cipher = new EncryptionContext($encryptionKey);
$this->setHandler(new HandshakePacketHandler(function() : void{
$this->onServerLoginSuccess();
}));
$this->logger->debug("Enabled encryption");
$this->setHandler(new HandshakePacketHandler(function() : void{
$this->onServerLoginSuccess();
}));
}else{
$this->onServerLoginSuccess();
}
$this->logger->debug("Enabled encryption");
}));
}else{
$this->onServerLoginSuccess();
}
}

View File

@ -44,6 +44,7 @@ class ResourcePackClientResponsePacket extends DataPacket implements Serverbound
protected function decodePayload(PacketSerializer $in) : void{
$this->status = $in->getByte();
$entryCount = $in->getLShort();
$this->packIds = [];
while($entryCount-- > 0){
$this->packIds[] = $in->getString();
}

View File

@ -1180,8 +1180,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$deltaAngle = abs($this->lastLocation->yaw - $to->yaw) + abs($this->lastLocation->pitch - $to->pitch);
if($delta > 0.0001 or $deltaAngle > 1.0){
$this->lastLocation = clone $to; //avoid PlayerMoveEvent modifying this
$ev = new PlayerMoveEvent($this, $from, $to);
$ev->call();
@ -1196,6 +1194,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return;
}
$this->lastLocation = $to;
$this->broadcastMovement();
$distance = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2));
@ -1218,8 +1217,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
}
protected function revertMovement(Location $from) : void{
$this->lastLocation = $from;
$this->setPosition($from);
$this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET);
}

View File

@ -1,15 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Comparison operation \"\\>\\=\" between 0 and 2 is always false\\.$#"
count: 1
path: ../../../src/block/Liquid.php
-
message: "#^If condition is always false\\.$#"
count: 1
path: ../../../src/block/Liquid.php
-
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 3