mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 07:55:31 +00:00
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/12191303914
This commit is contained in:
commit
6d2329128a
29
.github/workflows/pr-stale.yml
vendored
Normal file
29
.github/workflows/pr-stale.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: 'Clean up stale PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
days-before-issue-stale: -1
|
||||
days-before-issue-close: -1
|
||||
stale-pr-message: |
|
||||
This PR has been marked as "Waiting on Author", but we haven't seen any activity in 7 days.
|
||||
|
||||
If there is no further activity, it will be closed in 28 days.
|
||||
|
||||
Note for maintainers: Adding an assignee to the PR will prevent it from being marked as stale.
|
||||
|
||||
close-pr-message: |
|
||||
As this PR hasn't been updated for a while, unfortunately we'll have to close it.
|
||||
|
||||
days-before-pr-stale: 7
|
||||
days-before-pr-close: 28
|
||||
only-labels: "Status: Waiting on Author"
|
||||
close-pr-label: "Resolution: Abandoned"
|
||||
exempt-all-assignees: true
|
||||
|
@ -105,3 +105,12 @@ Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if
|
||||
- Event handler tests have been converted to PHPUnit tests by mocking `Server` and `Plugin` instances. Previously, these required integration tests for these dependencies.
|
||||
- Fixed various deprecation warnings in PHP 8.4.
|
||||
- `netresearch/jsonmapper` is now used at `5.0.0`. The PMMP fork of this library has been removed, as it is no longer needed.
|
||||
|
||||
# 5.23.1
|
||||
Released 5th December 2024.
|
||||
|
||||
## Fixes
|
||||
- Fixed signs not creating a tile when placed.
|
||||
|
||||
## Internals
|
||||
- Improved blockstate consistency check to detect tiles disappearing during refactors.
|
||||
|
@ -31,7 +31,7 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
public const BASE_VERSION = "5.23.1";
|
||||
public const BASE_VERSION = "5.23.2";
|
||||
public const IS_DEVELOPMENT_BUILD = true;
|
||||
public const BUILD_CHANNEL = "stable";
|
||||
|
||||
|
@ -54,6 +54,7 @@ use pocketmine\block\tile\MonsterSpawner as TileMonsterSpawner;
|
||||
use pocketmine\block\tile\NormalFurnace as TileNormalFurnace;
|
||||
use pocketmine\block\tile\Note as TileNote;
|
||||
use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
|
||||
use pocketmine\block\tile\Sign as TileSign;
|
||||
use pocketmine\block\tile\Smoker as TileSmoker;
|
||||
use pocketmine\block\tile\Tile;
|
||||
use pocketmine\block\utils\AmethystTrait;
|
||||
@ -1359,8 +1360,8 @@ final class VanillaBlocks{
|
||||
WoodType::WARPED => VanillaItems::WARPED_SIGN(...),
|
||||
WoodType::CHERRY => VanillaItems::CHERRY_SIGN(...),
|
||||
};
|
||||
self::register($idName("sign"), fn(BID $id) => new FloorSign($id, $name . " Sign", $signBreakInfo, $woodType, $signAsItem));
|
||||
self::register($idName("wall_sign"), fn(BID $id) => new WallSign($id, $name . " Wall Sign", $signBreakInfo, $woodType, $signAsItem));
|
||||
self::register($idName("sign"), fn(BID $id) => new FloorSign($id, $name . " Sign", $signBreakInfo, $woodType, $signAsItem), TileSign::class);
|
||||
self::register($idName("wall_sign"), fn(BID $id) => new WallSign($id, $name . " Wall Sign", $signBreakInfo, $woodType, $signAsItem), TileSign::class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\Utils;
|
||||
use function get_debug_type;
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
@ -95,11 +96,12 @@ class BlockTest extends TestCase{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array<string, int>
|
||||
* @return int[][]|string[][]
|
||||
* @phpstan-return array{array<string, int>, array<string, string>}
|
||||
*/
|
||||
public static function computeConsistencyCheckTable(RuntimeBlockStateRegistry $blockStateRegistry) : array{
|
||||
$newTable = [];
|
||||
$newTileMap = [];
|
||||
|
||||
$idNameLookup = [];
|
||||
//if we ever split up block registration into multiple registries (e.g. separating chemistry blocks),
|
||||
@ -118,36 +120,70 @@ class BlockTest extends TestCase{
|
||||
}
|
||||
$idName = $idNameLookup[$block->getTypeId()];
|
||||
$newTable[$idName] = ($newTable[$idName] ?? 0) + 1;
|
||||
}
|
||||
|
||||
return $newTable;
|
||||
$tileClass = $block->getIdInfo()->getTileClass();
|
||||
if($tileClass !== null){
|
||||
if(isset($newTileMap[$idName]) && $newTileMap[$idName] !== $tileClass){
|
||||
throw new AssumptionFailedError("Tile entity $tileClass for $idName is inconsistent");
|
||||
}
|
||||
$newTileMap[$idName] = $tileClass;
|
||||
}
|
||||
}
|
||||
return [$newTable, $newTileMap];
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param array<string, int> $actual
|
||||
* @phpstan-param array<string, int> $actualStateCounts
|
||||
* @phpstan-param array<string, string> $actualTiles
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function computeConsistencyCheckDiff(string $expectedFile, array $actual) : array{
|
||||
$expected = json_decode(Filesystem::fileGetContents($expectedFile), true, 2, JSON_THROW_ON_ERROR);
|
||||
public static function computeConsistencyCheckDiff(string $expectedFile, array $actualStateCounts, array $actualTiles) : array{
|
||||
$expected = json_decode(Filesystem::fileGetContents($expectedFile), true, 3, JSON_THROW_ON_ERROR);
|
||||
if(!is_array($expected)){
|
||||
throw new AssumptionFailedError("Old table should be array<string, int>");
|
||||
throw new AssumptionFailedError("Old table should be array{stateCounts: array<string, int>, tiles: array<string, string>}");
|
||||
}
|
||||
$expectedStates = $expected["stateCounts"] ?? [];
|
||||
$expectedTiles = $expected["tiles"] ?? [];
|
||||
if(!is_array($expectedStates)){
|
||||
throw new AssumptionFailedError("stateCounts should be an array, but have " . get_debug_type($expectedStates));
|
||||
}
|
||||
if(!is_array($expectedTiles)){
|
||||
throw new AssumptionFailedError("tiles should be an array, but have " . get_debug_type($expectedTiles));
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
foreach(Utils::promoteKeys($expected) as $typeName => $numStates){
|
||||
foreach(Utils::promoteKeys($expectedStates) as $typeName => $numStates){
|
||||
if(!is_string($typeName) || !is_int($numStates)){
|
||||
throw new AssumptionFailedError("Old table should be array<string, int>");
|
||||
}
|
||||
if(!isset($actual[$typeName])){
|
||||
if(!isset($actualStateCounts[$typeName])){
|
||||
$errors[] = "Removed block type $typeName ($numStates permutations)";
|
||||
}elseif($actual[$typeName] !== $numStates){
|
||||
$errors[] = "Block type $typeName permutation count changed: $numStates -> " . $actual[$typeName];
|
||||
}elseif($actualStateCounts[$typeName] !== $numStates){
|
||||
$errors[] = "Block type $typeName permutation count changed: $numStates -> " . $actualStateCounts[$typeName];
|
||||
}
|
||||
}
|
||||
foreach(Utils::stringifyKeys($actual) as $typeName => $numStates){
|
||||
if(!isset($expected[$typeName])){
|
||||
$errors[] = "Added block type $typeName (" . $actual[$typeName] . " permutations)";
|
||||
foreach(Utils::stringifyKeys($actualStateCounts) as $typeName => $numStates){
|
||||
if(!isset($expectedStates[$typeName])){
|
||||
$errors[] = "Added block type $typeName (" . $actualStateCounts[$typeName] . " permutations)";
|
||||
}
|
||||
}
|
||||
|
||||
foreach(Utils::promoteKeys($expectedTiles) as $typeName => $tile){
|
||||
if(!is_string($typeName) || !is_string($tile)){
|
||||
throw new AssumptionFailedError("Tile table should be array<string, string>");
|
||||
}
|
||||
if(isset($actualStateCounts[$typeName])){
|
||||
if(!isset($actualTiles[$typeName])){
|
||||
$errors[] = "$typeName no longer has a tile";
|
||||
}elseif($actualTiles[$typeName] !== $tile){
|
||||
$errors[] = "$typeName has changed tile ($tile -> " . $actualTiles[$typeName] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach(Utils::promoteKeys($actualTiles) as $typeName => $tile){
|
||||
if(isset($expectedStates[$typeName]) && !isset($expectedTiles[$typeName])){
|
||||
$errors[] = "$typeName has a tile when it previously didn't ($tile)";
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,8 +191,8 @@ class BlockTest extends TestCase{
|
||||
}
|
||||
|
||||
public function testConsistency() : void{
|
||||
$newTable = self::computeConsistencyCheckTable($this->blockFactory);
|
||||
$errors = self::computeConsistencyCheckDiff(__DIR__ . '/block_factory_consistency_check.json', $newTable);
|
||||
[$newTable, $newTileMap] = self::computeConsistencyCheckTable($this->blockFactory);
|
||||
$errors = self::computeConsistencyCheckDiff(__DIR__ . '/block_factory_consistency_check.json', $newTable, $newTileMap);
|
||||
|
||||
self::assertEmpty($errors, "Block factory consistency check failed:\n" . implode("\n", $errors));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,11 +28,11 @@ require dirname(__DIR__, 3) . '/vendor/autoload.php';
|
||||
|
||||
/* This script needs to be re-run after any intentional blockfactory change (adding or removing a block state). */
|
||||
|
||||
$newTable = BlockTest::computeConsistencyCheckTable(RuntimeBlockStateRegistry::getInstance());
|
||||
[$newTable, $newTiles] = BlockTest::computeConsistencyCheckTable(RuntimeBlockStateRegistry::getInstance());
|
||||
|
||||
$oldTablePath = __DIR__ . '/block_factory_consistency_check.json';
|
||||
if(file_exists($oldTablePath)){
|
||||
$errors = BlockTest::computeConsistencyCheckDiff($oldTablePath, $newTable);
|
||||
$errors = BlockTest::computeConsistencyCheckDiff($oldTablePath, $newTable, $newTiles);
|
||||
|
||||
if(count($errors) > 0){
|
||||
echo count($errors) . " changes detected:\n";
|
||||
@ -47,5 +47,6 @@ if(file_exists($oldTablePath)){
|
||||
}
|
||||
|
||||
ksort($newTable, SORT_STRING);
|
||||
ksort($newTiles, SORT_STRING);
|
||||
|
||||
file_put_contents($oldTablePath, json_encode($newTable, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT));
|
||||
file_put_contents($oldTablePath, json_encode(["stateCounts" => $newTable, "tiles" => $newTiles], JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT));
|
||||
|
Loading…
x
Reference in New Issue
Block a user