From 4b5f279a3ec99df1d24f775c3e3e08ab832957e9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 29 Apr 2021 19:13:52 +0100 Subject: [PATCH 1/7] UseItemOnEntityTransactionData: added missing type --- .../protocol/types/inventory/UseItemOnEntityTransactionData.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php b/src/pocketmine/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php index e77f6dc1d..d7fafbe9e 100644 --- a/src/pocketmine/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php +++ b/src/pocketmine/network/mcpe/protocol/types/inventory/UseItemOnEntityTransactionData.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction; class UseItemOnEntityTransactionData extends TransactionData{ public const ACTION_INTERACT = 0; public const ACTION_ATTACK = 1; + public const ACTION_ITEM_INTERACT = 2; /** @var int */ private $entityRuntimeId; From f195f24f4f6d7ffe636399513f0008c25c1f6173 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 1 May 2021 23:24:35 +0100 Subject: [PATCH 2/7] Upgrade to GitHub-native Dependabot (#4201) --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..993b80367 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 From c19d2fe8911f51fb6cbf32b1661ff5f64886bd25 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 1 May 2021 23:24:49 +0100 Subject: [PATCH 3/7] Bump phpstan/phpstan from 0.12.84 to 0.12.85 (#4199) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.84 to 0.12.85. - [Release notes](https://github.com/phpstan/phpstan/releases) - [Commits](https://github.com/phpstan/phpstan/compare/0.12.84...0.12.85) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 52a2c6a53..b6db48b2f 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "pocketmine/spl": "^0.4.0" }, "require-dev": { - "phpstan/phpstan": "0.12.84", + "phpstan/phpstan": "0.12.85", "phpstan/phpstan-phpunit": "^0.12.6", "phpstan/phpstan-strict-rules": "^0.12.2", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index 6df2a2c04..6f3056e85 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "8c9701fdb696fe1cd1952aa273f1bfa6", + "content-hash": "b03f33fc3d7e3ee6df116bd1e0b5b79e", "packages": [ { "name": "adhocore/json-comment", @@ -1009,16 +1009,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.84", + "version": "0.12.85", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5" + "reference": "20e6333c0067875ad7697cd8acdf245c6ef69d03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9c43f15da8798c8f30a4b099e6a94530a558cfd5", - "reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/20e6333c0067875ad7697cd8acdf245c6ef69d03", + "reference": "20e6333c0067875ad7697cd8acdf245c6ef69d03", "shasum": "" }, "require": { @@ -1049,7 +1049,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.84" + "source": "https://github.com/phpstan/phpstan/tree/0.12.85" }, "funding": [ { @@ -1065,7 +1065,7 @@ "type": "tidelift" } ], - "time": "2021-04-19T17:10:54+00:00" + "time": "2021-04-27T14:13:16+00:00" }, { "name": "phpstan/phpstan-phpunit", From c47ecb55c0a4a2492f1288736ffe87795d5b538a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 2 May 2021 13:22:31 +0100 Subject: [PATCH 4/7] Sign: Do not allow edits by any player except the one who placed it, and only while that player is online signs now become finalized if: - the player quits and rejoins (because the entity runtime ID of the player will not be the same) - the chunk is unloaded and reloaded (because the tagged entity runtime ID is not saved). closes #4198 --- src/pocketmine/block/SignPost.php | 5 ++++- src/pocketmine/tile/Sign.php | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index c63307446..945d20a7e 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -68,7 +68,10 @@ class SignPost extends Transparent{ $this->getLevelNonNull()->setBlock($blockReplace, BlockFactory::get(Block::WALL_SIGN, $this->meta), true); } - Tile::createTile(Tile::SIGN, $this->getLevelNonNull(), TileSign::createNBT($this, $face, $item, $player)); + $sign = Tile::createTile(Tile::SIGN, $this->getLevelNonNull(), TileSign::createNBT($this, $face, $item, $player)); + if($player !== null && $sign instanceof TileSign){ + $sign->setEditorEntityRuntimeId($player->getId()); + } return true; } diff --git a/src/pocketmine/tile/Sign.php b/src/pocketmine/tile/Sign.php index edfcf3735..747172be3 100644 --- a/src/pocketmine/tile/Sign.php +++ b/src/pocketmine/tile/Sign.php @@ -52,6 +52,9 @@ class Sign extends Spawnable{ /** @var string[] */ protected $text = ["", "", "", ""]; + /** @var int|null */ + protected $editorEntityRuntimeId = null; + protected function readSaveData(CompoundTag $nbt) : void{ if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){ //MCPE 1.2 save format $this->text = self::fixTextBlob($nbt->getString(self::TAG_TEXT_BLOB)); @@ -132,6 +135,22 @@ class Sign extends Spawnable{ return $this->text; } + /** + * Returns the entity runtime ID of the player who placed this sign. Only the player whose entity ID matches this + * one may edit the sign text. + * This is needed because as of 1.16.220, there is still no reliable way to detect when the MCPE client closed the + * sign edit GUI, so we have no way to know when the text is finalized. This limits editing of the text to only the + * player who placed it, and only while that player is online. + * We can say for sure that the sign is finalized if either of the following occurs: + * - The player quits (after rejoin, the player's entity runtimeID will be different). + * - The chunk is unloaded (on next load, the entity runtimeID will be null, because it's not saved). + */ + public function getEditorEntityRuntimeId() : ?int{ return $this->editorEntityRuntimeId; } + + public function setEditorEntityRuntimeId(?int $editorEntityRuntimeId) : void{ + $this->editorEntityRuntimeId = $editorEntityRuntimeId; + } + protected function addAdditionalSpawnData(CompoundTag $nbt) : void{ $nbt->setString(self::TAG_TEXT_BLOB, implode("\n", $this->text)); } @@ -158,6 +177,9 @@ class Sign extends Spawnable{ $removeFormat = $player->getRemoveFormat(); $ev = new SignChangeEvent($this->getBlock(), $player, array_map(function(string $line) use ($removeFormat) : string{ return TextFormat::clean($line, $removeFormat); }, $lines)); + if($this->editorEntityRuntimeId === null || $this->editorEntityRuntimeId !== $player->getId()){ + $ev->setCancelled(); + } $ev->call(); if(!$ev->isCancelled()){ From e6ff908e18da69a821e095f1856ea641322b8ce8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 4 May 2021 21:52:17 +0100 Subject: [PATCH 5/7] actions: update PHP versions --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57adef7e4..2807e2263 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: image: [ubuntu-20.04] - php: [7.3.27, 7.4.16] + php: [7.3.28, 7.4.18] steps: - uses: actions/checkout@v2 #needed for build.sh @@ -37,7 +37,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.3.27, 7.4.16] + php: [7.3.28, 7.4.18] steps: - uses: actions/checkout@v2 @@ -87,7 +87,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.3.27, 7.4.16] + php: [7.3.28, 7.4.18] steps: - uses: actions/checkout@v2 @@ -137,7 +137,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.3.27, 7.4.16] + php: [7.3.28, 7.4.18] steps: - uses: actions/checkout@v2 @@ -189,7 +189,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [7.3.27, 7.4.16] + php: [7.3.28, 7.4.18] steps: - uses: actions/checkout@v2 From a13b0c98a1b7fdd39a463207f641c1660f5874db Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 4 May 2021 22:18:18 +0100 Subject: [PATCH 6/7] Updated to PHP-CS-Fixer 3.0.0 --- .github/workflows/main.yml | 2 +- .gitignore | 1 + .php_cs => .php-cs-fixer.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename .php_cs => .php-cs-fixer.php (97%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2807e2263..8ff1cad46 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -278,4 +278,4 @@ jobs: tools: php-cs-fixer - name: Run PHP-CS-Fixer - run: php-cs-fixer fix --dry-run --diff --diff-format=udiff + run: php-cs-fixer fix --dry-run --diff diff --git a/.gitignore b/.gitignore index 0408f9670..2819313a1 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ Documentation/* # php-cs-fixer /.php_cs.cache +/.php-cs-fixer.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 97% rename from .php_cs rename to .php-cs-fixer.php index 48c5278b0..d2ea8dfa2 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -9,7 +9,7 @@ $finder = PhpCsFixer\Finder::create() ->notContains('#ifndef COMPILE') //preprocessor will break if these are changed ->notName('PocketMine.php'); -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config) ->setRiskyAllowed(true) ->setRules([ 'align_multiline_comment' => [ From c29cd8e2eb09fcc5aaf0a34e51e01c26fcc5bf13 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 4 May 2021 22:21:45 +0100 Subject: [PATCH 7/7] actions: added PHP script to update versions --- .github/workflows/update-php-versions.php | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/update-php-versions.php diff --git a/.github/workflows/update-php-versions.php b/.github/workflows/update-php-versions.php new file mode 100644 index 000000000..8b24812c8 --- /dev/null +++ b/.github/workflows/update-php-versions.php @@ -0,0 +1,51 @@ +