Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2022-07-19 20:20:10 +01:00
commit 040516054f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 23 additions and 12 deletions

View File

@ -39,7 +39,8 @@ use function substr;
use const SORT_STRING; use const SORT_STRING;
if(count($argv) !== 2){ if(count($argv) !== 2){
die("Provide a path to process"); fwrite(STDERR, "Provide a path to process\n");
exit(1);
} }
/** /**
@ -80,30 +81,24 @@ function generateMethodAnnotations(string $namespaceName, array $members) : stri
return implode("\n", $lines); return implode("\n", $lines);
} }
require dirname(__DIR__) . '/vendor/autoload.php'; function processFile(string $file) : void{
/** @var string $file */
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($argv[1], \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)) as $file){
if(substr($file, -4) !== ".php"){
continue;
}
$contents = file_get_contents($file); $contents = file_get_contents($file);
if($contents === false){ if($contents === false){
throw new \RuntimeException("Failed to get contents of $file"); throw new \RuntimeException("Failed to get contents of $file");
} }
if(preg_match("/(*ANYCRLF)^namespace (.+);$/m", $contents, $matches) !== 1 || preg_match('/(*ANYCRLF)^((final|abstract)\s+)?class /m', $contents) !== 1){ if(preg_match("/(*ANYCRLF)^namespace (.+);$/m", $contents, $matches) !== 1 || preg_match('/(*ANYCRLF)^((final|abstract)\s+)?class /m', $contents) !== 1){
continue; return;
} }
$shortClassName = basename($file, ".php"); $shortClassName = basename($file, ".php");
$className = $matches[1] . "\\" . $shortClassName; $className = $matches[1] . "\\" . $shortClassName;
if(!class_exists($className)){ if(!class_exists($className)){
continue; return;
} }
$reflect = new \ReflectionClass($className); $reflect = new \ReflectionClass($className);
$docComment = $reflect->getDocComment(); $docComment = $reflect->getDocComment();
if($docComment === false || preg_match("/(*ANYCRLF)^\s*\*\s*@generate-registry-docblock$/m", $docComment) !== 1){ if($docComment === false || preg_match("/(*ANYCRLF)^\s*\*\s*@generate-registry-docblock$/m", $docComment) !== 1){
continue; return;
} }
echo "Found registry in $file\n"; echo "Found registry in $file\n";
@ -117,3 +112,18 @@ foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($argv[1],
echo "No changes made to file $file\n"; echo "No changes made to file $file\n";
} }
} }
require dirname(__DIR__) . '/vendor/autoload.php';
if(is_dir($argv[1])){
/** @var string $file */
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($argv[1], \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)) as $file){
if(substr($file, -4) !== ".php"){
continue;
}
processFile($file);
}
}else{
processFile($argv[1]);
}

View File

@ -94,7 +94,8 @@ class Lava extends Liquid{
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4); $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
$entity->attack($ev); $entity->attack($ev);
$ev = new EntityCombustByBlockEvent($this, $entity, 15); //in java burns entities for 15 seconds - seems to be a parity issue in bedrock
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
$ev->call(); $ev->call();
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$entity->setOnFire($ev->getDuration()); $entity->setOnFire($ev->getDuration());