mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/13403469065
This commit is contained in:
commit
a43ebcf217
@ -51,8 +51,10 @@ use function array_unique;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function dirname;
|
||||
use function fclose;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function get_class;
|
||||
use function get_debug_type;
|
||||
@ -885,6 +887,44 @@ function cmdUpdateAll(array $argv) : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $argv
|
||||
*/
|
||||
function cmdDumpTable(array $argv) : int{
|
||||
$tableFile = $argv[2];
|
||||
$outputFile = $argv[3];
|
||||
|
||||
$output = fopen($outputFile, 'wb');
|
||||
if($output === false){
|
||||
fwrite(STDERR, "Failed to open output file: $outputFile\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
$table = loadUpgradeTableFromFile($tableFile, reverse: false);
|
||||
ksort($table, SORT_STRING);
|
||||
|
||||
foreach(Utils::stringifyKeys($table) as $oldName => $mappings){
|
||||
fwrite($output, "---------- MAPPING LIST: $oldName ----------\n");
|
||||
foreach($mappings as $mapping){
|
||||
$oldNbt = $mapping->old->toVanillaNbt();
|
||||
$oldNbt->setInt("version", $mapping->new->getVersion());
|
||||
|
||||
//intentionally not reused result of toVanillaNbt otherwise output wouldn't include version
|
||||
fwrite($output, "OLD: " . $mapping->old->toVanillaNbt() . "\n");
|
||||
if(!$oldNbt->equals($mapping->new->toVanillaNbt())){
|
||||
fwrite($output, "NEW: " . $mapping->new->toVanillaNbt() . "\n");
|
||||
}else{
|
||||
fwrite($output, "NEW: version bump only (" . $mapping->new->getVersion() . ")\n");
|
||||
}
|
||||
fwrite($output, "-----\n");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($output);
|
||||
\GlobalLogger::get()->info("Table dump file $outputFile generated successfully.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $argv
|
||||
*/
|
||||
@ -893,7 +933,8 @@ function main(array $argv) : int{
|
||||
"generate" => [["palette upgrade table file", "schema output file"], cmdGenerate(...)],
|
||||
"test" => [["palette upgrade table file", "schema output file"], cmdTest(...)],
|
||||
"update" => [["schema input file", "old palette file", "updated schema output file"], cmdUpdate(...)],
|
||||
"update-all" => [["schema folder", "path to BlockPaletteArchive"], cmdUpdateAll(...)]
|
||||
"update-all" => [["schema folder", "path to BlockPaletteArchive"], cmdUpdateAll(...)],
|
||||
"dump-table" => [["palette upgrade table file", "txt output file"], cmdDumpTable(...)]
|
||||
];
|
||||
|
||||
$selected = $argv[1] ?? null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user