Compare commits

..

7 Commits

Author SHA1 Message Date
a8d5e8c5f6 Release 3.25.1 2021-10-29 22:23:22 +01:00
089e62b44e Entity::spawnTo(): verify that the target player belongs to the same world as the entity
this should never be hit in the PM case, but it's an InvalidArgument rather than AssumptionFailedError because plugins can and do call this with bad things.
2021-10-29 18:54:00 +01:00
f1cc168d26 phpstan: exclude a couple of files from analysis temporarily
close #4472
2021-10-29 00:23:13 +01:00
f6e53f826b Fixed Anvil/McRegion chunks getting autosaved on first time, even when unchanged
setGenerated/setPopulated and friends set hasChanged = true, which causes the world to autosave them the first time around, even though they weren't modified.
2021-10-25 19:52:44 +01:00
986b4e0651 Enforce single-line PhpDoc for properties where possible 2021-10-21 20:32:37 +01:00
dc07ac33d3 protocol: fixed missing field of CraftRecipeAuto 2021-10-20 19:47:32 +01:00
9c5cec77b1 3.25.1 is next 2021-10-19 18:27:30 +01:00
12 changed files with 69 additions and 53 deletions

View File

@ -272,10 +272,10 @@ jobs:
- uses: actions/checkout@v2
- name: Setup PHP and tools
uses: shivammathur/setup-php@2.12.0
uses: shivammathur/setup-php@2.15.0
with:
php-version: 8.0
tools: php-cs-fixer
tools: php-cs-fixer:3.2
- name: Run PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --diff

View File

@ -62,6 +62,11 @@ return (new PhpCsFixer\Config)
],
'sort_algorithm' => 'alpha'
],
'phpdoc_line_span' => [
'property' => 'single',
'method' => null,
'const' => null
],
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'single_import_per_statement' => true,

View File

@ -9,3 +9,8 @@ Plugin developers should **only** update their required API to this version if y
# 3.25.0
- Added support for Minecraft: Bedrock Edition 1.17.40.
- Removed compatibility with earlier versions.
# 3.25.1
- Fixed autosave bug that caused unmodified chunks to be saved at least once (during the first autosave after they were loaded).
- `Entity->spawnTo()` now has an additional sanity check for matching worlds (might expose a few new errors in plugins).
- Fixed a missing field in `CraftRecipeAuto` item stack request type.

View File

@ -34,6 +34,9 @@ parameters:
analyseAndScan:
- build/php
- build/preprocessor
analyse:
- src/pocketmine/block/StoneSlab.php #overrides STONE constant
- src/pocketmine/item/Potion.php #overrides WATER constant
dynamicConstantNames:
- pocketmine\DEBUG
- pocketmine\IS_DEVELOPMENT_BUILD

View File

@ -563,7 +563,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
public function spawnTo(Player $player) : void{
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevelNonNull() === $this->level and $player->canSee($this) and !$this->isSpectator()){
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->canSee($this) and !$this->isSpectator()){
parent::spawnTo($player);
}
}

View File

@ -33,7 +33,7 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){
const _VERSION_INFO_INCLUDED = true;
const NAME = "PocketMine-MP";
const BASE_VERSION = "3.25.0";
const BASE_VERSION = "3.25.1";
const IS_DEVELOPMENT_BUILD = false;
const BUILD_NUMBER = 0;
const BUILD_CHANNEL = "stable";

View File

@ -1950,6 +1950,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
public function spawnTo(Player $player) : void{
if($player->getLevelNonNull() !== $this->level){
throw new \InvalidArgumentException("Player is not in the same world");
}
if(
!isset($this->hasSpawned[$player->getLoaderId()]) and
$this->chunk !== null and

View File

@ -135,6 +135,7 @@ class Anvil extends McRegion{
$result->setLightPopulated($chunk->getByte("LightPopulated", 0) !== 0);
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
$result->setGenerated();
$result->setChanged(false);
return $result;
}

View File

@ -201,6 +201,7 @@ class McRegion extends BaseLevelProvider{
$result->setLightPopulated($chunk->getByte("LightPopulated", 0) !== 0);
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
$result->setGenerated(true);
$result->setChanged(false);
return $result;
}

View File

@ -23,12 +23,38 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
/**
* Tells that the current transaction crafted the specified recipe, using the recipe book. This is effectively the same
* as the regular crafting result action.
*/
final class CraftRecipeAutoStackRequestAction extends ItemStackRequestAction{
use CraftRecipeStackRequestActionTrait;
/** @var int */
private $recipeId;
/** @var int */
private $repetitions;
final public function __construct(int $recipeId, int $repetitions){
$this->recipeId = $recipeId;
$this->repetitions = $repetitions;
}
public function getRecipeId() : int{ return $this->recipeId; }
public function getRepetitions() : int{ return $this->repetitions; }
public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_RECIPE_AUTO; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
$repetitions = $in->getByte();
return new self($recipeId, $repetitions);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
$out->putByte($this->repetitions);
}
}

View File

@ -23,11 +23,30 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
/**
* Tells that the current transaction crafted the specified recipe.
*/
final class CraftRecipeStackRequestAction extends ItemStackRequestAction{
use CraftRecipeStackRequestActionTrait;
/** @var int */
private $recipeId;
final public function __construct(int $recipeId){
$this->recipeId = $recipeId;
}
public function getRecipeId() : int{ return $this->recipeId; }
public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_RECIPE; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
return new self($recipeId);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
trait CraftRecipeStackRequestActionTrait{
/** @var int */
private $recipeId;
final public function __construct(int $recipeId){
$this->recipeId = $recipeId;
}
public function getRecipeId() : int{ return $this->recipeId; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
return new self($recipeId);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
}
}