mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Replace disallowed operators in src/crafting/
This commit is contained in:
@ -62,14 +62,14 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
*/
|
||||
public function __construct(array $shape, array $ingredients, array $results){
|
||||
$this->height = count($shape);
|
||||
if($this->height > 3 or $this->height <= 0){
|
||||
if($this->height > 3 || $this->height <= 0){
|
||||
throw new \InvalidArgumentException("Shaped recipes may only have 1, 2 or 3 rows, not $this->height");
|
||||
}
|
||||
|
||||
$shape = array_values($shape);
|
||||
|
||||
$this->width = strlen($shape[0]);
|
||||
if($this->width > 3 or $this->width <= 0){
|
||||
if($this->width > 3 || $this->width <= 0){
|
||||
throw new \InvalidArgumentException("Shaped recipes may only have 1, 2 or 3 columns, not $this->width");
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
}
|
||||
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
if($row[$x] !== ' ' and !isset($ingredients[$row[$x]])){
|
||||
if($row[$x] !== ' ' && !isset($ingredients[$row[$x]])){
|
||||
throw new \InvalidArgumentException("No item specified for symbol '" . $row[$x] . "'");
|
||||
}
|
||||
}
|
||||
@ -172,7 +172,7 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
|
||||
$given = $grid->getIngredient($reverse ? $this->width - $x - 1 : $x, $y);
|
||||
$required = $this->getIngredient($x, $y);
|
||||
if(!$required->equals($given, !$required->hasAnyDamageValue(), $required->hasNamedTag()) or $required->getCount() > $given->getCount()){
|
||||
if(!$required->equals($given, !$required->hasAnyDamageValue(), $required->hasNamedTag()) || $required->getCount() > $given->getCount()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -182,10 +182,10 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
}
|
||||
|
||||
public function matchesCraftingGrid(CraftingGrid $grid) : bool{
|
||||
if($this->width !== $grid->getRecipeWidth() or $this->height !== $grid->getRecipeHeight()){
|
||||
if($this->width !== $grid->getRecipeWidth() || $this->height !== $grid->getRecipeHeight()){
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->matchInputMap($grid, false) or $this->matchInputMap($grid, true);
|
||||
return $this->matchInputMap($grid, false) || $this->matchInputMap($grid, true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user