Convert ItemFactory to singleton

This commit is contained in:
Dylan K. Taylor
2020-04-24 00:18:31 +01:00
parent 13d784cd0c
commit 5a94af40e2
19 changed files with 546 additions and 546 deletions

View File

@ -99,6 +99,7 @@ class Flat extends Generator{
$result = [];
$split = array_map('\trim', explode(',', $layers));
$y = 0;
$itemFactory = ItemFactory::getInstance();
foreach($split as $line){
preg_match('#^(?:(\d+)[x|*])?(.+)$#', $line, $matches);
if(count($matches) !== 3){
@ -107,7 +108,7 @@ class Flat extends Generator{
$cnt = $matches[1] !== "" ? (int) $matches[1] : 1;
try{
$b = ItemFactory::fromString($matches[2])->getBlock();
$b = $itemFactory->fromString($matches[2])->getBlock();
}catch(\InvalidArgumentException $e){
throw new InvalidGeneratorOptionsException("Invalid preset layer \"$line\": " . $e->getMessage(), 0, $e);
}