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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace pocketmine\network; namespace pocketmine\network;
use pocketmine\event\player\PlayerDuplicateLoginEvent;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use function count; use function count;
use function spl_object_id; use function spl_object_id;
@ -59,33 +58,6 @@ class NetworkSessionManager{
$this->updateSessions[spl_object_id($session)] = $session; $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. * Returns the number of known connected sessions.
*/ */
@ -93,6 +65,9 @@ class NetworkSessionManager{
return count($this->sessions); return count($this->sessions);
} }
/** @return NetworkSession[] */
public function getSessions() : array{ return $this->sessions; }
/** /**
* Updates all sessions which need it. * Updates all sessions which need it.
*/ */

View File

@ -30,6 +30,7 @@ use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\entity\Human; use pocketmine\entity\Human;
use pocketmine\entity\Living; use pocketmine\entity\Living;
use pocketmine\event\player\PlayerDuplicateLoginEvent;
use pocketmine\event\server\DataPacketReceiveEvent; use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\event\server\DataPacketSendEvent; use pocketmine\event\server\DataPacketSendEvent;
use pocketmine\form\Form; use pocketmine\form\Form;
@ -607,43 +608,68 @@ class NetworkSession{
} }
$this->logger->debug("Xbox Live authenticated: " . ($this->authenticated ? "YES" : "NO")); $this->logger->debug("Xbox Live authenticated: " . ($this->authenticated ? "YES" : "NO"));
//TODO: make player data loading async $checkXUID = (bool) $this->server->getConfigGroup()->getProperty("player.verify-xuid", true);
//TODO: we shouldn't be loading player data here at all, but right now we don't have any choice :( $myXUID = $this->info instanceof XboxLivePlayerInfo ? $this->info->getXuid() : "";
$this->cachedOfflinePlayerData = $this->server->getOfflinePlayerData($this->info->getUsername()); $kickForXUIDMismatch = function(string $xuid) use ($checkXUID, $myXUID) : bool{
if((bool) $this->server->getConfigGroup()->getProperty("player.verify-xuid", true)){ if($checkXUID && $myXUID !== $xuid){
$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()){
//TODO: Longer term, we should be identifying playerdata using something more reliable, like XUID or UUID. //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. //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 //Side note: this will also prevent offline players hijacking XBL playerdata on online servers, since their
//XUID will always be empty. //XUID will always be empty.
$this->disconnect("XUID does not match (possible impersonation attempt)"); $this->disconnect("XUID does not match (possible impersonation attempt)");
return; return true;
}else{ }
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"); $this->logger->debug("XUID match");
} }
} }
if($this->manager->kickDuplicates($this)){ if(EncryptionContext::$ENABLED){
if(EncryptionContext::$ENABLED){ $this->server->getAsyncPool()->submitTask(new PrepareEncryptionTask($clientPubKey, function(string $encryptionKey, string $handshakeJwt) : void{
$this->server->getAsyncPool()->submitTask(new PrepareEncryptionTask($clientPubKey, function(string $encryptionKey, string $handshakeJwt) : void{ if(!$this->connected){
if(!$this->connected){ return;
return; }
} $this->sendDataPacket(ServerToClientHandshakePacket::create($handshakeJwt), true); //make sure this gets sent before encryption is enabled
$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->setHandler(new HandshakePacketHandler(function() : void{
$this->onServerLoginSuccess(); $this->onServerLoginSuccess();
}));
$this->logger->debug("Enabled encryption");
})); }));
}else{ $this->logger->debug("Enabled encryption");
$this->onServerLoginSuccess(); }));
} }else{
$this->onServerLoginSuccess();
} }
} }

View File

@ -44,6 +44,7 @@ class ResourcePackClientResponsePacket extends DataPacket implements Serverbound
protected function decodePayload(PacketSerializer $in) : void{ protected function decodePayload(PacketSerializer $in) : void{
$this->status = $in->getByte(); $this->status = $in->getByte();
$entryCount = $in->getLShort(); $entryCount = $in->getLShort();
$this->packIds = [];
while($entryCount-- > 0){ while($entryCount-- > 0){
$this->packIds[] = $in->getString(); $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); $deltaAngle = abs($this->lastLocation->yaw - $to->yaw) + abs($this->lastLocation->pitch - $to->pitch);
if($delta > 0.0001 or $deltaAngle > 1.0){ if($delta > 0.0001 or $deltaAngle > 1.0){
$this->lastLocation = clone $to; //avoid PlayerMoveEvent modifying this
$ev = new PlayerMoveEvent($this, $from, $to); $ev = new PlayerMoveEvent($this, $from, $to);
$ev->call(); $ev->call();
@ -1196,6 +1194,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return; return;
} }
$this->lastLocation = $to;
$this->broadcastMovement(); $this->broadcastMovement();
$distance = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2)); $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{ protected function revertMovement(Location $from) : void{
$this->lastLocation = $from;
$this->setPosition($from); $this->setPosition($from);
$this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET); $this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET);
} }

View File

@ -1,15 +1,5 @@
parameters: parameters:
ignoreErrors: 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\\.$#" message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 3 count: 3