Merge branch 'next-major' into modern-world-support

This commit is contained in:
Dylan K. Taylor 2022-04-19 15:32:44 +01:00
commit be863015bf
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
17 changed files with 217 additions and 183 deletions

View File

@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
image: [ubuntu-20.04]
php: [8.0.16]
php: [8.0.18]
steps:
- name: Build and prepare PHP cache
@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [8.0.16]
php: [8.0.18]
steps:
- uses: actions/checkout@v2
@ -69,7 +69,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [8.0.16]
php: [8.0.18]
steps:
- uses: actions/checkout@v2
@ -107,7 +107,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [8.0.16]
php: [8.0.18]
steps:
- uses: actions/checkout@v2
@ -147,7 +147,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [8.0.16]
php: [8.0.18]
steps:
- uses: actions/checkout@v2

View File

@ -79,3 +79,31 @@ Released 28th March 2022.
### Gameplay
- Reduced the appearance of ghost items in unsupported gameplay scenarios using client prediction information. This fixes, for example, the appearance of ghost items when right-clicking on a filled flower pot.
# 4.2.6
Released 1st April 2022.
## Fixes
- Fixed buffer length underflow crash in `LoginPacket` handling.
# 4.2.7
Released 15th April 2022.
## General
- Added lots more documentation (in comments) about the `aliases` section in `pocketmine.yml`. You can read about this feature in the `aliases` section of the [updated `pocketmine.yml` template](/resources/pocketmine.yml).
- Improved wording of documentation of `PlayerPreLoginEvent`.
## Fixes
- Fixed core server crash when a plugin causes another plugin to be disabled during a scheduled task.
- Fixed core server crash when loading a plugin with an abstract main class.
- Fixed ghost items in many interaction situations (most notably, using projectiles while looking at an entity or block).
- Implemented a workaround for a client teleport bug which led to player positions not updating properly when using ender pearls.
- Fixed buggy movement when teleporting the player during `PlayerToggleSneakEvent`, `PlayerToggleSprintEvent`, `PlayerToggleSwimEvent` and `PlayerToggleGlideEvent`.
# 4.2.8
Released 17th April 2022.
## Fixes
- Fixed a memory leak in RakLib which could result in a server crash when players stay online for a long time.
- Fixed server crash when attempting to load a corrupted empty resource pack.
- Fixed users with the same name with differerently cased letters being able to duplicate items (userdata is matched by case-insensitive name).

View File

@ -36,13 +36,13 @@
"netresearch/jsonmapper": "^4.0",
"pocketmine/bedrock-block-upgrade-schema": "dev-master@dev",
"pocketmine/bedrock-data": "~1.6.0+bedrock-1.18.10",
"pocketmine/bedrock-protocol": "~8.0.0+bedrock-1.18.10",
"pocketmine/bedrock-protocol": "~8.0.2+bedrock-1.18.10",
"pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "^0.2.0",
"pocketmine/color": "^0.2.0",
"pocketmine/errorhandler": "^0.6.0",
"pocketmine/locale-data": "~2.4.2",
"pocketmine/locale-data": "~2.6.0",
"pocketmine/log": "^0.4.0",
"pocketmine/log-pthreads": "^0.4.0",
"pocketmine/math": "^0.4.0",
@ -54,7 +54,7 @@
"webmozart/path-util": "^2.3"
},
"require-dev": {
"phpstan/phpstan": "1.5.1",
"phpstan/phpstan": "1.5.6",
"phpstan/phpstan-phpunit": "^1.1.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.2"

195
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": "6cdee46b6600bda56158d10581fa928e",
"content-hash": "751c8e23dc6763022e8a780f0083f629",
"packages": [
{
"name": "adhocore/json-comment",
@ -302,16 +302,16 @@
},
{
"name": "pocketmine/bedrock-protocol",
"version": "8.0.1+bedrock-1.18.10",
"version": "8.0.2+bedrock-1.18.10",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "a740f6095b35278c0e0dac6db84a5e4d2456b113"
"reference": "d1f1afdbb4ea61ea52eb511a79ee1ca561da349c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/a740f6095b35278c0e0dac6db84a5e4d2456b113",
"reference": "a740f6095b35278c0e0dac6db84a5e4d2456b113",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/d1f1afdbb4ea61ea52eb511a79ee1ca561da349c",
"reference": "d1f1afdbb4ea61ea52eb511a79ee1ca561da349c",
"shasum": ""
},
"require": {
@ -325,7 +325,7 @@
"ramsey/uuid": "^4.1"
},
"require-dev": {
"phpstan/phpstan": "1.4.5",
"phpstan/phpstan": "1.5.3",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5"
@ -343,9 +343,9 @@
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
"support": {
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
"source": "https://github.com/pmmp/BedrockProtocol/tree/8.0.1+bedrock-1.18.10"
"source": "https://github.com/pmmp/BedrockProtocol/tree/8.0.2+bedrock-1.18.10"
},
"time": "2022-02-21T03:31:48+00:00"
"time": "2022-04-01T21:55:10+00:00"
},
{
"name": "pocketmine/binaryutils",
@ -563,16 +563,16 @@
},
{
"name": "pocketmine/locale-data",
"version": "2.4.3",
"version": "2.6.2",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Language.git",
"reference": "4d0b081f1a79407e087968ea76aaf330db6ea2b5"
"reference": "eae9303493884edcc5321b50002a5dc956a36a23"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Language/zipball/4d0b081f1a79407e087968ea76aaf330db6ea2b5",
"reference": "4d0b081f1a79407e087968ea76aaf330db6ea2b5",
"url": "https://api.github.com/repos/pmmp/Language/zipball/eae9303493884edcc5321b50002a5dc956a36a23",
"reference": "eae9303493884edcc5321b50002a5dc956a36a23",
"shasum": ""
},
"type": "library",
@ -580,9 +580,9 @@
"description": "Language resources used by PocketMine-MP",
"support": {
"issues": "https://github.com/pmmp/Language/issues",
"source": "https://github.com/pmmp/Language/tree/2.4.3"
"source": "https://github.com/pmmp/Language/tree/2.6.2"
},
"time": "2022-01-25T23:18:24+00:00"
"time": "2022-04-10T20:44:40+00:00"
},
{
"name": "pocketmine/log",
@ -754,16 +754,16 @@
},
{
"name": "pocketmine/raklib",
"version": "0.14.3",
"version": "0.14.4",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "4798576fec0364266dce23b368a7fec5e5de7927"
"reference": "1ea8e3b95a1b6bf785dc27d76578657be4185f42"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/4798576fec0364266dce23b368a7fec5e5de7927",
"reference": "4798576fec0364266dce23b368a7fec5e5de7927",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/1ea8e3b95a1b6bf785dc27d76578657be4185f42",
"reference": "1ea8e3b95a1b6bf785dc27d76578657be4185f42",
"shasum": ""
},
"require": {
@ -775,7 +775,7 @@
"pocketmine/log": "^0.3.0 || ^0.4.0"
},
"require-dev": {
"phpstan/phpstan": "1.3.3",
"phpstan/phpstan": "1.5.4",
"phpstan/phpstan-strict-rules": "^1.0"
},
"type": "library",
@ -791,9 +791,9 @@
"description": "A RakNet server implementation written in PHP",
"support": {
"issues": "https://github.com/pmmp/RakLib/issues",
"source": "https://github.com/pmmp/RakLib/tree/0.14.3"
"source": "https://github.com/pmmp/RakLib/tree/0.14.4"
},
"time": "2022-01-10T21:29:48+00:00"
"time": "2022-04-17T18:42:17+00:00"
},
{
"name": "pocketmine/raklib-ipc",
@ -957,25 +957,24 @@
},
{
"name": "ramsey/uuid",
"version": "4.2.3",
"version": "4.3.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df"
"reference": "8505afd4fea63b81a85d3b7b53ac3cb8dc347c28"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df",
"reference": "fc9bb7fb5388691fd7373cd44dcb4d63bbcf24df",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/8505afd4fea63b81a85d3b7b53ac3cb8dc347c28",
"reference": "8505afd4fea63b81a85d3b7b53ac3cb8dc347c28",
"shasum": ""
},
"require": {
"brick/math": "^0.8 || ^0.9",
"ext-ctype": "*",
"ext-json": "*",
"php": "^7.2 || ^8.0",
"ramsey/collection": "^1.0",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-php80": "^1.14"
"php": "^8.0",
"ramsey/collection": "^1.0"
},
"replace": {
"rhumsaa/uuid": "self.version"
@ -1012,9 +1011,6 @@
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "4.x-dev"
},
"captainhook": {
"force-install": true
}
@ -1039,7 +1035,7 @@
],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
"source": "https://github.com/ramsey/uuid/tree/4.2.3"
"source": "https://github.com/ramsey/uuid/tree/4.3.1"
},
"funding": [
{
@ -1051,7 +1047,7 @@
"type": "tidelift"
}
],
"time": "2021-09-25T23:10:38+00:00"
"time": "2022-03-27T21:42:02+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1135,89 +1131,6 @@
],
"time": "2021-10-20T20:35:02+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.25.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c",
"reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.23-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-03-04T08:16:47+00:00"
},
{
"name": "symfony/polyfill-php81",
"version": "v1.25.0",
@ -1816,16 +1729,16 @@
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.6.0",
"version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706"
"reference": "77a32518733312af16a44300404e945338981de3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706",
"reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3",
"reference": "77a32518733312af16a44300404e945338981de3",
"shasum": ""
},
"require": {
@ -1860,9 +1773,9 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0"
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1"
},
"time": "2022-01-04T19:58:01+00:00"
"time": "2022-03-15T21:29:03+00:00"
},
{
"name": "phpspec/prophecy",
@ -1933,16 +1846,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.5.1",
"version": "1.5.6",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "cc67578d9afd0f5f2545067285613d7a529aefac"
"reference": "799dd8c2d2c9c704bb55d2078078cb970cf0f6d1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/cc67578d9afd0f5f2545067285613d7a529aefac",
"reference": "cc67578d9afd0f5f2545067285613d7a529aefac",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/799dd8c2d2c9c704bb55d2078078cb970cf0f6d1",
"reference": "799dd8c2d2c9c704bb55d2078078cb970cf0f6d1",
"shasum": ""
},
"require": {
@ -1968,7 +1881,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.5.1"
"source": "https://github.com/phpstan/phpstan/tree/1.5.6"
},
"funding": [
{
@ -1988,7 +1901,7 @@
"type": "tidelift"
}
],
"time": "2022-03-28T15:34:48+00:00"
"time": "2022-04-15T11:13:37+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
@ -2413,16 +2326,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.19",
"version": "9.5.20",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807"
"reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35ea4b7f3acabb26f4bb640f8c30866c401da807",
"reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/12bc8879fb65aef2138b26fc633cb1e3620cffba",
"reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba",
"shasum": ""
},
"require": {
@ -2500,7 +2413,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.19"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.20"
},
"funding": [
{
@ -2512,7 +2425,7 @@
"type": "github"
}
],
"time": "2022-03-15T09:57:31+00:00"
"time": "2022-04-01T12:37:26+00:00"
},
{
"name": "sebastian/cli-parser",
@ -2880,16 +2793,16 @@
},
{
"name": "sebastian/environment",
"version": "5.1.3",
"version": "5.1.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "388b6ced16caa751030f6a69e588299fa09200ac"
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac",
"reference": "388b6ced16caa751030f6a69e588299fa09200ac",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"shasum": ""
},
"require": {
@ -2931,7 +2844,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.3"
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.4"
},
"funding": [
{
@ -2939,7 +2852,7 @@
"type": "github"
}
],
"time": "2020-09-28T05:52:38+00:00"
"time": "2022-04-03T09:37:03+00:00"
},
{
"name": "sebastian/exporter",

View File

@ -173,10 +173,31 @@ console:
title-tick: true
aliases:
#Examples:
#showtheversion: version
##This section allows you to add, remove or remap command aliases.
##A single alias can call one or more other commands (or aliases).
##Aliases defined here will override any command aliases declared by plugins or PocketMine-MP itself.
##To remove an alias, set it to [], like so (note that prefixed aliases like "pocketmine:stop" will remain and can't
##be removed):
#stop: []
##Commands are not removed, only their aliases. You can still refer to a command using its full (prefixed)
##name, even if all its aliases are overwritten. The full name is usually something like "pocketmine:commandname" or
##"pluginname:commandname".
#abort: [pocketmine:stop]
##To add an alias, list the command(s) that it calls:
#showtheversion: [version]
#savestop: [save-all, stop]
##To invoke another command with arguments, use $1 to pass the first argument, $2 for the second etc:
#giveadmin: [op $1] ## `giveadmin alex` -> `op alex`
#kill: [suicide, say "I tried to kill $1"] ## `kill alex` -> `suicide` + `say "I tried to kill alex"`
#giverandom: [give $1 $2, say "Someone has just received a $2!"] ## `giverandom alex diamond` -> `give alex diamond` + `say "Someone has just received a diamond!"`
##To change an existing command alias and make it do something else:
#tp: [suicide]
worlds:
#These settings will override the generator set in server.properties and allows loading multiple worlds
#Example:

View File

@ -132,6 +132,7 @@ use function get_class;
use function ini_set;
use function is_array;
use function is_dir;
use function is_object;
use function is_resource;
use function is_string;
use function json_decode;
@ -1617,7 +1618,7 @@ class Server{
"reportPaste" => base64_encode($dump->getEncodedData())
], 10, [], $postUrlError);
if($reply !== null && ($data = json_decode($reply->getBody())) !== null){
if($reply !== null && is_object($data = json_decode($reply->getBody()))){
if(isset($data->crashId) && isset($data->crashUrl)){
$reportId = $data->crashId;
$reportUrl = $data->crashUrl;

View File

@ -82,6 +82,10 @@ class FlowerPot extends Flowable{
return false;
}
return $this->isValidPlant($block);
}
private function isValidPlant(Block $block) : bool{
return
$block instanceof Cactus ||
$block instanceof DeadBush ||
@ -115,8 +119,26 @@ class FlowerPot extends Flowable{
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$plant = $item->getBlock();
if(!$this->canAddPlant($plant)){
return false;
if($this->plant !== null){
if($this->isValidPlant($plant)){
//for some reason, vanilla doesn't remove the contents of the pot if the held item is plantable
//and will also cause a new plant to be placed if clicking on the side
return false;
}
$removedItems = [$this->plant->asItem()];
if($player !== null){
//this one just has to be a weirdo :(
//this is the only block that directly adds items to the player inventory instead of just dropping items
$removedItems = $player->getInventory()->addItem(...$removedItems);
}
foreach($removedItems as $drops){
$this->position->getWorld()->dropItem($this->position->add(0.5, 0.5, 0.5), $drops);
}
$this->setPlant(null);
$this->position->getWorld()->setBlock($this->position, $this);
return true;
}
$this->setPlant($plant);

View File

@ -37,6 +37,7 @@ use function implode;
use function is_numeric;
use function ksort;
use function min;
use function sort;
use function strtolower;
use const SORT_FLAG_CASE;
use const SORT_NATURAL;
@ -105,7 +106,7 @@ class HelpCommand extends VanillaCommand{
$lang = $sender->getLanguage();
$description = $cmd->getDescription();
$descriptionString = $description instanceof Translatable ? $lang->translate($description) : $description;
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_header($commandName)
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_header($cmd->getName())
->format(TextFormat::YELLOW . "--------- " . TextFormat::WHITE, TextFormat::YELLOW . " ---------"));
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_description(TextFormat::WHITE . $descriptionString)
->prefix(TextFormat::GOLD));
@ -115,6 +116,11 @@ class HelpCommand extends VanillaCommand{
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_usage(TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $usageString)))
->prefix(TextFormat::GOLD));
$aliases = $cmd->getAliases();
sort($aliases, SORT_NATURAL);
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_aliases(TextFormat::WHITE . implode(", ", $aliases))
->prefix(TextFormat::GOLD));
return true;
}
}

View File

@ -768,17 +768,29 @@ abstract class Entity{
}
protected function broadcastMovement(bool $teleport = false) : void{
$this->server->broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create(
$this->id,
$this->getOffsetPosition($this->location),
$this->location->pitch,
$this->location->yaw,
$this->location->yaw,
(
($teleport ? MoveActorAbsolutePacket::FLAG_TELEPORT : 0) |
($this->onGround ? MoveActorAbsolutePacket::FLAG_GROUND : 0)
)
)]);
if($teleport){
//TODO: HACK! workaround for https://github.com/pmmp/PocketMine-MP/issues/4394
//this happens because MoveActor*Packet doesn't clear interpolation targets on the client, so the entity
//snaps to the teleport position, but then lerps back to the original position if a normal movement for the
//entity was recently broadcasted. This can be seen with players throwing ender pearls.
//TODO: remove this if the bug ever gets fixed (lol)
foreach($this->hasSpawned as $player){
$this->despawnFrom($player);
$this->spawnTo($player);
}
}else{
$this->server->broadcastPackets($this->hasSpawned, [MoveActorAbsolutePacket::create(
$this->id,
$this->getOffsetPosition($this->location),
$this->location->pitch,
$this->location->yaw,
$this->location->yaw,
(
//TODO: if the above hack for #4394 gets removed, we should be setting FLAG_TELEPORT here
($this->onGround ? MoveActorAbsolutePacket::FLAG_GROUND : 0)
)
)]);
}
}
protected function broadcastMotion() : void{

View File

@ -31,7 +31,7 @@ use function count;
/**
* Called when a player connects to the server, prior to authentication taking place.
* Cancelling this event will cause the player to be disconnected with the kick message set.
* Set a kick reason to cancel the event and disconnect the player with the kick message set.
*
* This event should be used to decide if the player may continue to login to the server. Do things like checking
* bans, whitelisting, server-full etc here.

View File

@ -1197,6 +1197,12 @@ final class KnownTranslationFactory{
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_DESCRIPTION, []);
}
public static function pocketmine_command_help_specificCommand_aliases(Translatable|string $aliasList) : Translatable{
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_ALIASES, [
"aliasList" => $aliasList,
]);
}
public static function pocketmine_command_help_specificCommand_description(Translatable|string $description) : Translatable{
return new Translatable(KnownTranslationKeys::POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_DESCRIPTION, [
"description" => $description,
@ -1829,6 +1835,10 @@ final class KnownTranslationFactory{
]);
}
public static function pocketmine_plugin_mainClassAbstract() : Translatable{
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_MAINCLASSABSTRACT, []);
}
public static function pocketmine_plugin_mainClassNotFound() : Translatable{
return new Translatable(KnownTranslationKeys::POCKETMINE_PLUGIN_MAINCLASSNOTFOUND, []);
}

View File

@ -262,6 +262,7 @@ final class KnownTranslationKeys{
public const POCKETMINE_COMMAND_GIVE_DESCRIPTION = "pocketmine.command.give.description";
public const POCKETMINE_COMMAND_GIVE_USAGE = "pocketmine.command.give.usage";
public const POCKETMINE_COMMAND_HELP_DESCRIPTION = "pocketmine.command.help.description";
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_ALIASES = "pocketmine.command.help.specificCommand.aliases";
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_DESCRIPTION = "pocketmine.command.help.specificCommand.description";
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_HEADER = "pocketmine.command.help.specificCommand.header";
public const POCKETMINE_COMMAND_HELP_SPECIFICCOMMAND_USAGE = "pocketmine.command.help.specificCommand.usage";
@ -379,6 +380,7 @@ final class KnownTranslationKeys{
public const POCKETMINE_PLUGIN_INVALIDMANIFEST = "pocketmine.plugin.invalidManifest";
public const POCKETMINE_PLUGIN_LOAD = "pocketmine.plugin.load";
public const POCKETMINE_PLUGIN_LOADERROR = "pocketmine.plugin.loadError";
public const POCKETMINE_PLUGIN_MAINCLASSABSTRACT = "pocketmine.plugin.mainClassAbstract";
public const POCKETMINE_PLUGIN_MAINCLASSNOTFOUND = "pocketmine.plugin.mainClassNotFound";
public const POCKETMINE_PLUGIN_MAINCLASSWRONGTYPE = "pocketmine.plugin.mainClassWrongType";
public const POCKETMINE_PLUGIN_RESTRICTEDNAME = "pocketmine.plugin.restrictedName";

View File

@ -125,6 +125,7 @@ use function get_class;
use function in_array;
use function json_encode;
use function ksort;
use function strcasecmp;
use function strlen;
use function strtolower;
use function substr;
@ -635,7 +636,7 @@ class NetworkSession{
continue;
}
$info = $existingSession->getPlayerInfo();
if($info !== null && ($info->getUsername() === $this->info->getUsername() || $info->getUuid()->equals($this->info->getUuid()))){
if($info !== null && (strcasecmp($info->getUsername(), $this->info->getUsername()) === 0 || $info->getUuid()->equals($this->info->getUuid()))){
if($kickForXUIDMismatch($info instanceof XboxLivePlayerInfo ? $info->getXuid() : "")){
return;
}

View File

@ -228,8 +228,10 @@ class InGamePacketHandler extends PacketHandler{
$this->player->jump();
}
//TODO: this packet has WAYYYYY more useful information that we're not using
$this->player->handleMovement($newPos);
if(!$this->forceMoveSync){
//TODO: this packet has WAYYYYY more useful information that we're not using
$this->player->handleMovement($newPos);
}
$packetHandled = true;
@ -457,13 +459,10 @@ class InGamePacketHandler extends PacketHandler{
if(!$this->player->consumeHeldItem()){
$hungerAttr = $this->player->getAttributeMap()->get(Attribute::HUNGER) ?? throw new AssumptionFailedError();
$hungerAttr->markSynchronized(false);
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
}
return true;
}
if(!$this->player->useHeldItem()){
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
}
$this->player->useHeldItem();
return true;
}
@ -483,7 +482,6 @@ class InGamePacketHandler extends PacketHandler{
* Internal function used to execute rollbacks when an action fails on a block.
*/
private function onFailedBlockAction(Vector3 $blockPos, ?int $face) : void{
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
if($blockPos->distanceSquared($this->player->getLocation()) < 10000){
$blocks = $blockPos->sidesArray();
if($face !== null){
@ -512,14 +510,10 @@ class InGamePacketHandler extends PacketHandler{
//TODO: use transactiondata for rollbacks here
switch($data->getActionType()){
case UseItemOnEntityTransactionData::ACTION_INTERACT:
if(!$this->player->interactEntity($target, $data->getClickPosition())){
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
}
$this->player->interactEntity($target, $data->getClickPosition());
return true;
case UseItemOnEntityTransactionData::ACTION_ATTACK:
if(!$this->player->attackEntity($target)){
$this->inventoryManager->syncSlot($this->player->getInventory(), $this->player->getInventory()->getHeldItemIndex());
}
$this->player->attackEntity($target);
return true;
}

View File

@ -166,6 +166,14 @@ class PluginManager{
)));
return null;
}
$reflect = new \ReflectionClass($mainClass); //this shouldn't throw; we already checked that it exists
if(!$reflect->isInstantiable()){
$this->server->getLogger()->error($language->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
$description->getName(),
KnownTranslationFactory::pocketmine_plugin_mainClassAbstract()
)));
return null;
}
$permManager = PermissionManager::getInstance();
foreach($description->getPermissions() as $permsGroup){
@ -463,8 +471,12 @@ class PluginManager{
}
public function tickSchedulers(int $currentTick) : void{
foreach($this->enabledPlugins as $p){
$p->getScheduler()->mainThreadHeartbeat($currentTick);
foreach($this->enabledPlugins as $pluginName => $p){
if(isset($this->enabledPlugins[$pluginName])){
//the plugin may have been disabled as a result of updating other plugins' schedulers, and therefore
//removed from enabledPlugins; however, foreach will still see it due to copy-on-write
$p->getScheduler()->mainThreadHeartbeat($currentTick);
}
}
}

View File

@ -64,6 +64,13 @@ class ZippedResourcePack implements ResourcePack{
if(!file_exists($zipPath)){
throw new ResourcePackException("File not found");
}
$size = filesize($zipPath);
if($size === false){
throw new ResourcePackException("Unable to determine size of file");
}
if($size === 0){
throw new ResourcePackException("Empty file, probably corrupted");
}
$archive = new \ZipArchive();
if(($openResult = $archive->open($zipPath)) !== true){

View File

@ -90,3 +90,8 @@ parameters:
count: 2
path: ../../../src/world/format/io/region/RegionLoader.php
-
message: "#^Negated boolean expression is always true\\.$#"
count: 1
path: ../../../src/network/mcpe/handler/InGamePacketHandler.php