Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2021-12-10 19:15:57 +00:00
commit a94b88424e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
11 changed files with 62 additions and 16 deletions

View File

@ -8,6 +8,9 @@
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/pmmp/PocketMine-MP?label=release&sort=semver">
<a href="https://hub.docker.com/r/pmmp/pocketmine-mp"><img src="https://img.shields.io/docker/v/pmmp/pocketmine-mp?logo=docker&label=image" alt="Docker image version (latest semver)" /></a>
<a href="https://discord.gg/bmSAZBG"><img src="https://img.shields.io/discord/373199722573201408?label=discord&color=7289DA&logo=discord" alt="Discord" /></a>
<br>
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/pmmp/PocketMine-MP/total?label=downloads%40total">
<img alt="GitHub release (latest by SemVer)" src="https://img.shields.io/github/downloads/pmmp/PocketMine-MP/latest/total">
</p>
## Getting started

View File

@ -12,3 +12,12 @@ Plugin developers should **only** update their required API to this version if y
# 3.26.1
- Fixed a bug in chunk sending that caused double chests to not be paired, signs to be blank, and various other issues.
# 3.26.2
- Improved error messages shown by `start.cmd`, `start.sh` and `start.ps1` when the PHP binary was not found.
- The value of PHPRC is now shown when erroring out due to unsatisfied PHP requirements.
- Removed restriction on the range of valid channels for `auto-updater.channel` in `pocketmine.yml`.
# 3.26.3
- `PlayerExperienceChangeEvent->setNewProgress()` now performs range checks. This fixes the root of a very old and confusing crash bug which took several years to identify the cause of.
- Note that the defective plugin(s) which caused this problem will still cause a server crash, but the plugin responsible will now get blamed correctly.

View File

@ -1523,3 +1523,27 @@ Please note that this was not written with plugins in mind and its API may chang
### Misc
- Added support for emotes.
# 4.0.1
Released 9th December 2021.
## General
- Added a script `tools/ping-server.php`. This was sitting in my workspace for many years.
- `Minecraft network interface running` messages are no longer shown if RakLib was prevented from starting.
## Fixes
### Core
- Fixed server crash when `FallingBlock` has invalid block data that it can't understand.
- Fixed server crash when loading chunks containing tiles outside the world bounds.
- Fixed server crash when loading LevelDB chunks containing blockstates which are invalid or not yet supported - they are now treated as corrupted instead.
- Fixed `level.dat` becoming corrupted by world saves when the disk is full - now it will still fail to save, but it will leave the original data intact. Previously it would destroy the data and leave behind an empty file.
- Fixed configs becoming corrupted when saved when the disk is full - now they'll still fail to save, but the original file will remain intact.
### API
- Fixed mistakes in the 4.0.0 changelog:
- Removal of `Player->getLowerCaseName()` is now mentioned.
- `CreativeInventory::reset()` is the successor to `Item::initCreativeItems()`, not `CreativeInventory::init()`.
- Note that the changelog when viewing from the 4.0.0 GitHub release will remain the same; only the changelog in the current repo will be different.
- `Config->save()` will no longer write empty data to the file when using JSON and the data fails to encode - an exception will be thrown instead.
- `StringToItemParser` now returns the correct items for `bamboo`, `shulker_box`, `stone_slab`, `stone_stairs` and `tall_grass`.
- `StringToItemParser` now recognizes `slime` and `slime_block` (these were previously missing).

View File

@ -213,6 +213,8 @@ JIT_WARNING
}
critical_error("PHP binary used: " . $binary);
critical_error("Loaded php.ini: " . (($file = php_ini_loaded_file()) !== false ? $file : "none"));
$phprc = getenv("PHPRC");
critical_error("Value of PHPRC environment variable: " . ($phprc === false ? "" : $phprc));
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
echo PHP_EOL;
exit(1);

View File

@ -206,7 +206,7 @@ class SimpleCommandMap implements CommandMap{
foreach($matches[0] as $k => $_){
for($i = 1; $i <= 2; ++$i){
if($matches[$i][$k] !== ""){
$args[$k] = stripslashes($matches[$i][$k]);
$args[$k] = $i === 1 ? stripslashes($matches[$i][$k]) : $matches[$i][$k];
break;
}
}

View File

@ -27,7 +27,6 @@ use pocketmine\entity\utils\ExperienceUtils;
use pocketmine\event\player\PlayerExperienceChangeEvent;
use pocketmine\item\Durable;
use pocketmine\item\enchantment\VanillaEnchantments;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Limits;
use pocketmine\world\sound\XpCollectSound;
use pocketmine\world\sound\XpLevelUpSound;
@ -36,7 +35,6 @@ use function ceil;
use function count;
use function max;
use function min;
use function sprintf;
class ExperienceManager{
@ -146,9 +144,6 @@ class ExperienceManager{
$xpLevel = (int) $newLevel;
$xpProgress = $newLevel - (int) $newLevel;
if($xpProgress > 1.0){
throw new AssumptionFailedError(sprintf("newLevel - (int) newLevel should never be bigger than 1, but have %.53f (newLevel=%.53f)", $xpProgress, $newLevel));
}
return $this->setXpAndProgress($xpLevel, $xpProgress);
}

View File

@ -71,7 +71,7 @@ class ItemEntity extends Entity{
if($item->isNull()){
throw new \InvalidArgumentException("Item entity must have a non-air item with a count of at least 1");
}
$this->item = $item;
$this->item = clone $item;
parent::__construct($location, $nbt);
}

View File

@ -82,6 +82,9 @@ class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{
}
public function setNewProgress(?float $newProgress) : void{
if($newProgress < 0.0 || $newProgress > 1.0){
throw new \InvalidArgumentException("XP progress must be in range 0-1");
}
$this->newProgress = $newProgress;
}
}

View File

@ -31,6 +31,7 @@ use function array_push;
use function array_slice;
use function array_values;
use function count;
use function mb_scrub;
abstract class WritableBookBase extends Item{
public const TAG_PAGES = "pages"; //TAG_List<TAG_Compound>
@ -168,12 +169,12 @@ abstract class WritableBookBase extends Item{
if($pages->getTagType() === NBT::TAG_Compound){ //PE format
/** @var CompoundTag $page */
foreach($pages as $page){
$this->pages[] = new WritableBookPage($page->getString(self::TAG_PAGE_TEXT), $page->getString(self::TAG_PAGE_PHOTONAME, ""));
$this->pages[] = new WritableBookPage(mb_scrub($page->getString(self::TAG_PAGE_TEXT), 'UTF-8'), $page->getString(self::TAG_PAGE_PHOTONAME, ""));
}
}elseif($pages->getTagType() === NBT::TAG_String){ //PC format
/** @var StringTag $page */
foreach($pages as $page){
$this->pages[] = new WritableBookPage($page->getValue());
$this->pages[] = new WritableBookPage(mb_scrub($page->getValue(), 'UTF-8'));
}
}
}

View File

@ -28,6 +28,7 @@ use pocketmine\permission\PermissionParser;
use pocketmine\permission\PermissionParserException;
use function array_map;
use function array_values;
use function get_debug_type;
use function is_array;
use function is_string;
use function preg_match;
@ -85,7 +86,18 @@ class PluginDescription{
* @param string|mixed[] $yamlString
*/
public function __construct($yamlString){
$this->loadMap(!is_array($yamlString) ? yaml_parse($yamlString) : $yamlString);
if(is_string($yamlString)){
$map = yaml_parse($yamlString);
if($map === false){
throw new PluginDescriptionParseException("YAML parsing error in plugin manifest");
}
if(!is_array($map)){
throw new PluginDescriptionParseException("Invalid structure of plugin manifest, expected array but have " . get_debug_type($map));
}
}else{
$map = $yamlString;
}
$this->loadMap($map);
}
/**

View File

@ -153,6 +153,8 @@ class UpdateChecker{
if($currentVersion->getBuild() > 0 && $currentVersion->compare($newVersion) > 0){
$this->updateInfo = $updateInfo;
}else{
$this->logger->debug("API reported version is an older version or the same version (" . $newVersion->getFullVersion() . "), not showing notification");
}
}
@ -160,12 +162,7 @@ class UpdateChecker{
* Returns the channel used for update checking (stable, beta, dev)
*/
public function getChannel() : string{
$channel = strtolower($this->server->getConfigGroup()->getPropertyString("auto-updater.preferred-channel", "stable"));
if($channel !== "stable" and $channel !== "beta" and $channel !== "alpha" and $channel !== "development"){
$channel = "stable";
}
return $channel;
return strtolower($this->server->getConfigGroup()->getPropertyString("auto-updater.preferred-channel", "stable"));
}
/**