Use str_starts_with and str_contains instead of strpos (#5482)

This commit is contained in:
Alexey
2022-12-31 00:41:30 +03:00
committed by GitHub
parent 0d169b4e80
commit 0d31b25fba
6 changed files with 18 additions and 16 deletions

View File

@ -70,7 +70,7 @@ use function explode;
use function max;
use function microtime;
use function mt_rand;
use function strpos;
use function str_starts_with;
use function strtolower;
class ParticleCommand extends VanillaCommand{
@ -208,17 +208,17 @@ class ParticleCommand extends VanillaCommand{
return new EntityFlameParticle();
}
if(strpos($name, "iconcrack_") === 0){
if(str_starts_with($name, "iconcrack_")){
$d = explode("_", $name);
if(count($d) === 3){
return new ItemBreakParticle(ItemFactory::getInstance()->get((int) $d[1], (int) $d[2]));
}
}elseif(strpos($name, "blockcrack_") === 0){
}elseif(str_starts_with($name, "blockcrack_")){
$d = explode("_", $name);
if(count($d) === 2){
return new TerrainParticle(BlockFactory::getInstance()->get(((int) $d[1]) & 0xff, ((int) $d[1]) >> 12));
}
}elseif(strpos($name, "blockdust_") === 0){
}elseif(str_starts_with($name, "blockdust_")){
$d = explode("_", $name);
if(count($d) >= 4){
return new DustParticle(new Color(((int) $d[1]) & 0xff, ((int) $d[2]) & 0xff, ((int) $d[3]) & 0xff, isset($d[4]) ? ((int) $d[4]) & 0xff : 255));